Skip to content

Commit

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

ByteBufVisitor added in apache#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.
  • Loading branch information
lhotari authored and Anup Ghatage committed Jul 12, 2024
1 parent a28837b commit a9524d1
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 a9524d1

Please sign in to comment.