merlimat commented on a change in pull request #940: BookieProtoEncoding: 
remove unnecessary slice() call
URL: https://github.com/apache/bookkeeper/pull/940#discussion_r159591151
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtoEncoding.java
 ##########
 @@ -289,8 +289,8 @@ public Object decode(ByteBuf buffer)
                 entryId = buffer.readLong();
 
                 if (rc == BookieProtocol.EOK) {
-                    ByteBuf content = buffer.slice();
-                    return new BookieProtocol.ReadResponse(version, rc, 
ledgerId, entryId, content.retain());
+                    return new BookieProtocol.ReadResponse(version, rc,
 
 Review comment:
   I'm not 100% sure the `slice()` can be avoided, because we would have to 
double check all the places that are touching that buffer.
   
   I think a better option here is to use `buffer.retainedSlice()` which 
achieves both goals (and also lets the resulting `ByteBuf` slice object to be 
pooled. 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to