Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Commit 252ac38

Browse files
committed
Simplify MemSegBuf.compact implementation
1 parent 0f303c7 commit 252ac38

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/main/java/io/netty/buffer/api/memseg/MemSegBuf.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,7 @@ public void compact() {
393393
if (distance == 0) {
394394
return;
395395
}
396-
int pos = 0;
397-
var cursor = openCursor();
398-
while (cursor.readLong()) {
399-
setLongAtOffset(seg, pos, ByteOrder.BIG_ENDIAN, cursor.getLong());
400-
pos += Long.BYTES;
401-
}
402-
while (cursor.readByte()) {
403-
setByteAtOffset(seg, pos, cursor.getByte());
404-
pos++;
405-
}
396+
seg.copyFrom(seg.asSlice(roff, woff - roff));
406397
roff -= distance;
407398
woff -= distance;
408399
}

0 commit comments

Comments
 (0)