dschneider-pivotal commented on a change in pull request #6773:
URL: https://github.com/apache/geode/pull/6773#discussion_r696849078



##########
File path: 
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisSortedSet.java
##########
@@ -478,6 +498,54 @@ private int 
getMaxElementsToReturn(AbstractSortedSetRangeOptions<?> rangeOptions
     return result;
   }
 
+  private int removeEntriesByRange(Region<RedisKey, RedisData> region, 
RedisKey key, int min,
+      int max) {
+    int start = getBoundedStartIndex(min, scoreSet.size());
+    int end = getBoundedEndIndex(max, scoreSet.size());
+    int rangeSize = end - start;
+
+    if (rangeSize <= 0 || start == scoreSet.size()) {
+      return 0;
+    }
+
+    int membersRemoved = 0;
+    Iterator<AbstractOrderedSetEntry> entryIterator =
+        scoreSet.getIndexRange(start, rangeSize, false);
+    RemsDeltaInfo deltaInfo = null;
+
+    while (entryIterator.hasNext()) {
+      AbstractOrderedSetEntry next = entryIterator.next();
+      if (deltaInfo == null) {
+        deltaInfo = new RemsDeltaInfo();
+      }
+      deltaInfo.add(next.member);
+      membersRemoved++;
+    }
+
+    if (deltaInfo != null) {
+      membersRemoveAll(deltaInfo);

Review comment:
       instead of calling membersRemoveAll here (which ends up doing another 
iteration) how about doing the local remove in the previous while loop that 
iterates over entryIterator? It looks to me like that iterator supports remove 
(take a look at how zpop does it) so I think you could just do this in the 
while loop to do the local removal:      
         entryIterator.remove();
         members.remove(next.member);
   




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