Skip to content

Commit

Permalink
Remove unused code from ByteBufVisitor (#4383)
Browse files Browse the repository at this point in the history
### Motivation

ByteBufVisitor added in #4196 contains some code that isn't used and covered by unit tests.
It's better to remove such code since it makes it harder to reason about the solution. The ByteBufVisitor solution will unwrap all direct buffers that can be unwrapped without the code that is to be removed. I believe that I forgot this code from some earlier phase of the solution where it was necessary to include this.
I ran some local tests and didn't see that the code was used for the original purpose that it was added for (supporting read-only buffers).

### Changes

Remove the unused code.

(cherry picked from commit 84fd255)
  • Loading branch information
lhotari authored and shoothzj committed May 25, 2024
1 parent df88638 commit cc76792
Showing 1 changed file with 0 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ private void passBufferToCallback(ByteBuf visitBuffer, int visitIndex, int visit
handleArray(visitBuffer.array(), visitBuffer.arrayOffset() + visitIndex, visitLength);
} else if (visitBuffer.hasMemoryAddress() && callback.acceptsMemoryAddress(callbackContext)) {
callback.visitBuffer(callbackContext, visitBuffer, visitIndex, visitLength);
} else if (callback.acceptsMemoryAddress(callbackContext) && visitBuffer.isDirect()
&& visitBuffer.alloc().isDirectBufferPooled()) {
// read-only buffers need to be copied before they can be directly accessed
ByteBuf copyBuffer = visitBuffer.copy(visitIndex, visitLength);
callback.visitBuffer(callbackContext, copyBuffer, 0, visitLength);
copyBuffer.release();
} else {
// fallback to reading the visited buffer into the copy buffer in a loop
byte[] copyBuffer = TL_COPY_BUFFER.get();
Expand Down

0 comments on commit cc76792

Please sign in to comment.