BewareMyPower commented on code in PR #18154:
URL: https://github.com/apache/pulsar/pull/18154#discussion_r1001821538


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -658,6 +658,16 @@ protected LastCumulativeAck initialValue() {
     private boolean flushRequired = false;
 
     public synchronized void update(final MessageIdImpl messageId, final 
BitSetRecyclable bitSetRecyclable) {
+        if (messageId.equals(this.messageId)) {
+            if (this.bitSetRecyclable != null && bitSetRecyclable != null
+                    && bitSetRecyclable.nextSetBit(0) > 
this.bitSetRecyclable.nextSetBit(0)) {
+                this.bitSetRecyclable.recycle();
+                set(messageId, bitSetRecyclable);
+                flushRequired = true;
+            }
+            return;
+        }
+
         if (messageId.compareTo(this.messageId) > 0) {

Review Comment:
   We already have the compare sult, I think we can improve it like
   
   ```java
           int compareResult = messageId.compareTo(this.messageId);
           if (messageId.compareTo(this.messageId) > 0) {
               /* ... */
           } else if (compareResult == 0) {
               /* compare bitSetRecyclable... */
           }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to