Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.List;

import static com.mongodb.assertions.Assertions.assertFalse;
import static com.mongodb.assertions.Assertions.assertTrue;
import static com.mongodb.assertions.Assertions.notNull;
import static java.lang.String.format;
Expand Down Expand Up @@ -176,6 +175,7 @@ private ByteBuf getCurrentByteBuffer() {
if (currentByteBuffer == null) {
currentByteBuffer = getByteBufferAtIndex(curBufferIndex);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional]

Was this change intentional or accidental? I ma pointing it out just in case it was an accident. If not, feel free to merge.

Copy link
Member Author

@vbabanin vbabanin Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change was intentional - i thought visually separating the branches (after the recent changes in #1675) might help make the logic a bit more apparent. Thank you for flagging it!

if (currentByteBuffer.hasRemaining()) {
return currentByteBuffer;
}
Expand All @@ -185,11 +185,6 @@ private ByteBuf getCurrentByteBuffer() {
return currentByteBuffer;
}

private ByteBuf getNextByteBuffer() {
assertFalse(bufferList.get(curBufferIndex).hasRemaining());
return getByteBufferAtIndex(++curBufferIndex);
}

private ByteBuf getByteBufferAtIndex(final int index) {
if (bufferList.size() < index + 1) {
ByteBuf buffer = bufferProvider.getBuffer(index >= (MAX_SHIFT - INITIAL_SHIFT)
Expand Down Expand Up @@ -459,7 +454,7 @@ private int writeOnBuffers(final String str,

if (c < 0x80) {
if (remaining == 0) {
curBuffer = getNextByteBuffer();
curBuffer = getCurrentByteBuffer();
curBufferPos = 0;
curBufferLimit = curBuffer.limit();
}
Expand Down