bugfix: packed input reading was broken for runs longer than 128 words.
This commit is contained in:
parent
252acd2b32
commit
98500483c9
2 changed files with 10 additions and 6 deletions
|
@ -94,7 +94,7 @@ public final class PackedInputStream implements ReadableByteChannel {
|
||||||
throw new Error("Should always have non-empty buffer here.");
|
throw new Error("Should always have non-empty buffer here.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int runLength = inBuf.get() * 8;
|
int runLength = (0xff & (int)inBuf.get()) * 8;
|
||||||
|
|
||||||
if (runLength > outEnd - outPtr) {
|
if (runLength > outEnd - outPtr) {
|
||||||
throw new Error("Packed input did not end cleanly on a segment boundary");
|
throw new Error("Packed input did not end cleanly on a segment boundary");
|
||||||
|
@ -105,8 +105,7 @@ public final class PackedInputStream implements ReadableByteChannel {
|
||||||
}
|
}
|
||||||
} else if (tag == (byte)0xff) {
|
} else if (tag == (byte)0xff) {
|
||||||
|
|
||||||
int runLength = inBuf.get() * 8;
|
int runLength = (0xff & (int)inBuf.get()) * 8;
|
||||||
|
|
||||||
|
|
||||||
if (inBuf.remaining() >= runLength) {
|
if (inBuf.remaining() >= runLength) {
|
||||||
//# Fast path.
|
//# Fast path.
|
||||||
|
|
|
@ -51,8 +51,6 @@ class SerializePackedSuite extends FunSuite {
|
||||||
|
|
||||||
(bytes) should equal (unpacked)
|
(bytes) should equal (unpacked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test("SimplePacking") {
|
test("SimplePacking") {
|
||||||
|
@ -80,5 +78,12 @@ class SerializePackedSuite extends FunSuite {
|
||||||
|
|
||||||
expectPacksTo(Array(0,0,0,0,2,0,0,0, 0,0,0,0,0,0,1,0, 0,0,0,0,0,0,0,0),
|
expectPacksTo(Array(0,0,0,0,2,0,0,0, 0,0,0,0,0,0,1,0, 0,0,0,0,0,0,0,0),
|
||||||
Array(0x10,2, 0x40,1, 0,0))
|
Array(0x10,2, 0x40,1, 0,0))
|
||||||
|
|
||||||
|
expectPacksTo(Array.tabulate[Byte](8 * 200)((n) => 0),
|
||||||
|
Array(0, 199.toByte))
|
||||||
|
|
||||||
|
expectPacksTo(Array.tabulate[Byte](8 * 200)((n) => 1),
|
||||||
|
Array.concat(Array(0xff.toByte, 1,1,1,1,1,1,1,1, 199.toByte),
|
||||||
|
Array.tabulate[Byte](8 * 199)((n) => 1)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue