014-code commented on code in PR #16395:
URL: https://github.com/apache/dubbo/pull/16395#discussion_r3655948336


##########
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/state/BitList.java:
##########
@@ -114,16 +114,26 @@ public synchronized E getByIndex(int index) {
     }
 
     /**
-     * And operation between two bitList. Return a new cloned list.
-     * TailList in source bitList will be totally saved even if it is not 
appeared in the target bitList.
+     * And operation between two bitList.
      *
      * @param target target bitList
-     * @return this bitList only contains those elements contain in both two 
list and source bitList's tailList
+     * @return this bitList only contains elements contained in both lists
      */
     public synchronized BitList<E> and(BitList<E> target) {
-        rootSet.and(target.rootSet);
-        if (target.getTailList() != null) {
-            target.getTailList().forEach(this::addToTailList);
+        if (originList == target.originList) {

Review Comment:
   `==` is intentional here.
   
   This branch is only used as a fast path when both `BitList`s share the same 
backing `originList` instance, where the bit indexes have the same meaning and 
`BitSet.and()` is safe.
   
   If the two `BitList`s are backed by different `originList`s, even if they 
contain the same elements, we still fall back to the element-based intersection 
logic below.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to