From: Shawn O. Pearce Date: Wed, 7 Jul 2010 15:52:46 +0000 (-0700) Subject: Define a constant for 127 in DeltaEncoder X-Git-Tag: v0.9.1~157^2~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=711bd3e3d035b22e41bda32a9463cef3e2dca7a7;p=jgit.git Define a constant for 127 in DeltaEncoder The special value 127 here means how many bytes we can put into a single insert command. Rather than use the magical value 127, lets name it to better document the code. Change-Id: I5a326f4380f6ac87987fa833e9477700e984a88e Signed-off-by: Shawn O. Pearce --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/DeltaEncoder.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/DeltaEncoder.java index 9254acc1b8..9984eb1ff1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/DeltaEncoder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/DeltaEncoder.java @@ -70,6 +70,9 @@ public class DeltaEncoder { /** Maximum number of bytes used by a copy instruction. */ private static final int MAX_COPY_CMD_SIZE = 8; + /** Maximum length that an an insert command can encode at once. */ + private static final int MAX_INSERT_DATA_SIZE = 127; + private final OutputStream out; private final byte[] buf = new byte[MAX_COPY_CMD_SIZE * 4]; @@ -151,7 +154,7 @@ public class DeltaEncoder { */ public void insert(byte[] text, int off, int cnt) throws IOException { while (0 < cnt) { - int n = Math.min(127, cnt); + int n = Math.min(MAX_INSERT_DATA_SIZE, cnt); out.write((byte) n); out.write(text, off, n); off += n;