Browse Source

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 <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
711bd3e3d0
  1. 5
      org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/DeltaEncoder.java

5
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. */ /** Maximum number of bytes used by a copy instruction. */
private static final int MAX_COPY_CMD_SIZE = 8; 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 OutputStream out;
private final byte[] buf = new byte[MAX_COPY_CMD_SIZE * 4]; 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 { public void insert(byte[] text, int off, int cnt) throws IOException {
while (0 < cnt) { while (0 < cnt) {
int n = Math.min(127, cnt); int n = Math.min(MAX_INSERT_DATA_SIZE, cnt);
out.write((byte) n); out.write((byte) n);
out.write(text, off, n); out.write(text, off, n);
off += n; off += n;

Loading…
Cancel
Save