You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/01/24 08:45:04 UTC

[GitHub] [rocketmq] dongeforever commented on a change in pull request #2843: [ISSUE #2842] Optimize the code that HAClient handles the Bod

dongeforever commented on a change in pull request #2843:
URL: https://github.com/apache/rocketmq/pull/2843#discussion_r790517247



##########
File path: store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
##########
@@ -452,11 +452,13 @@ private boolean dispatchReadRequest() {
                     }
 
                     if (diff >= (msgHeaderSize + bodySize)) {
-                        byte[] bodyData = new byte[bodySize];
-                        this.byteBufferRead.position(this.dispatchPosition + msgHeaderSize);
-                        this.byteBufferRead.get(bodyData);
+                        if (bodySize > 0) {
+                            byte[] bodyData = new byte[bodySize];
+                            this.byteBufferRead.position(this.dispatchPosition + msgHeaderSize);

Review comment:
       Here will cause an unnecessary copy of the data.
   
   If boySize == 0, just ignore the appendToCommitlog.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org