Skip to content

Commit

Permalink
refactor: always try the first buffer in cache
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 committed Aug 14, 2024
1 parent 7d1180d commit cb67f05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public ByteBuffer get(int minCapacity) {
@Override
public void release(ByteBuffer buffer) {
buffer.clear();
buffers.addLast(buffer);
buffers.addFirst(buffer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void testGetAndReleaseMultipleBuffers() {
bufferSupplier.release(buffer1);
bufferSupplier.release(buffer2);

ByteBuffer result1 = bufferSupplier.get(5);
ByteBuffer result2 = bufferSupplier.get(10);
ByteBuffer result2 = bufferSupplier.get(5);
ByteBuffer result1 = bufferSupplier.get(10);
assertSame(buffer1, result1);
assertSame(buffer2, result2);
assertEquals(0, result1.position());
Expand Down

0 comments on commit cb67f05

Please sign in to comment.