Use a list instead of a set for the current group in GroupedListHelper to save memory. This is a partial rollback of f745e99db7632cfb2145b6926f961e85f9084bc5, but that part of the change was unnecessary -- we are already ensuring that an element isn't added twice in GroupedListHelper#add by adding it to elements.
--
MOS_MIGRATED_REVID=116560479
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 cd633b8..09674d4 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
@@ -312,7 +312,7 @@
public static class GroupedListHelper<E> implements Iterable<E> {
// Non-final only for removal.
private List<Object> groupedList;
- private CompactHashSet<E> currentGroup = null;
+ private List<E> currentGroup = null;
private final CompactHashSet<E> elements;
public GroupedListHelper() {
@@ -361,7 +361,7 @@
*/
public void startGroup() {
Preconditions.checkState(currentGroup == null, this);
- currentGroup = CompactHashSet.create();
+ currentGroup = new ArrayList<>();
}
/** Ends a group started with {@link #startGroup}. */