Simplify MemSegBuf.compact implementation

This commit is contained in:
Chris Vest 2020-12-16 16:03:36 +01:00
parent 0f303c7971
commit 252ac38305

View File

@ -393,16 +393,7 @@ class MemSegBuf extends RcSupport<Buf, MemSegBuf> implements Buf {
if (distance == 0) {
return;
}
int pos = 0;
var cursor = openCursor();
while (cursor.readLong()) {
setLongAtOffset(seg, pos, ByteOrder.BIG_ENDIAN, cursor.getLong());
pos += Long.BYTES;
}
while (cursor.readByte()) {
setByteAtOffset(seg, pos, cursor.getByte());
pos++;
}
seg.copyFrom(seg.asSlice(roff, woff - roff));
roff -= distance;
woff -= distance;
}