steve-sienk commented on a change in pull request #7519:
URL: https://github.com/apache/geode/pull/7519#discussion_r839945915



##########
File path: 
geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/collections/SizeableByteArrayList.java
##########
@@ -102,22 +103,13 @@ public int lastIndexOf(Object o) {
   }
 
   /**
-   * @param remove in order (smallest to largest) list of indexes to remove
+   * @param indexes list of indexes to remove
    */
-  public void removeIndexes(List<Integer> remove) {
-    int removeIndex = 0;
-    int firstIndexToRemove = remove.get(0);
-    ListIterator<byte[]> iterator = listIterator(firstIndexToRemove);
-
-    // Iterates only through the indexes to remove
-    for (int i = firstIndexToRemove; i <= remove.get(remove.size() - 1); i++) {
-      byte[] element = iterator.next();
-      if (i == remove.get(removeIndex)) {
-        iterator.remove();
-        memberOverhead -= calculateByteArrayOverhead(element);
-        removeIndex++;
-      }
+  public void removeIndexes(List<Integer> indexes) {
+    if(indexes.size() > 1) {
+      indexes.sort(Comparator.reverseOrder());
     }
+    indexes.forEach(index -> this.remove((int)index));

Review comment:
       Ah, gotchya. I was wondering where the complexity was coming from -- 
performance code, I see. I'll revert. Though, I'll add an `int endIndexToRemove 
= remove.get(remove.size() - 1);` variable to make the for loop a bit easier to 
read.




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