diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/util/GroupedList.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/util/GroupedList.java b/src/main/java/com/google/devtools/build/lib/util/GroupedList.java index 475e38518b..11bef3fcc2 100644 --- a/src/main/java/com/google/devtools/build/lib/util/GroupedList.java +++ b/src/main/java/com/google/devtools/build/lib/util/GroupedList.java @@ -343,6 +343,9 @@ public class GroupedList<T> implements Iterable<Collection<T>> { * GroupedListHelper. */ private static <E> List<Object> remove(List<Object> elements, Set<E> toRemove) { + if (toRemove.isEmpty()) { + return elements; + } int removedCount = 0; // elements.size is an upper bound of the needed size. Since normally removal happens just // before the list is finished and compressed, optimizing this size isn't a concern. @@ -369,8 +372,15 @@ public class GroupedList<T> implements Iterable<Collection<T>> { } } } + // removedCount can be larger if elements had duplicates and the duplicate was also in toRemove. Preconditions.checkState( - removedCount == toRemove.size(), "%s %s %s", elements, toRemove, newElements); + removedCount >= toRemove.size(), + "removedCount=%s, toRemove.size()=%s, elements=%s toRemove=%s newElements=%s", + removedCount, + toRemove.size(), + elements, + toRemove, + newElements); return newElements; } |