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>
/** 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];
*/
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;