Skip to content

Commit f2292de

Browse files
gk5885copybara-github
authored andcommitted
Change CelUnknownSet to use Sets.union and SetView.immutableCopy, which builds the copy using a pre-sized builder to avoid churn on the internal hash table.
PiperOrigin-RevId: 778585485
1 parent cdcd194 commit f2292de

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

runtime/src/main/java/dev/cel/runtime/CelUnknownSet.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.google.auto.value.AutoValue;
1818
import com.google.common.collect.ImmutableSet;
19+
import com.google.common.collect.Sets;
1920

2021
/**
2122
* Unknown set representation.
@@ -65,14 +66,8 @@ private static CelUnknownSet create(
6566

6667
public static CelUnknownSet union(CelUnknownSet lhs, CelUnknownSet rhs) {
6768
return create(
68-
ImmutableSet.<CelAttribute>builder()
69-
.addAll(lhs.attributes())
70-
.addAll(rhs.attributes())
71-
.build(),
72-
ImmutableSet.<Long>builder()
73-
.addAll(lhs.unknownExprIds())
74-
.addAll(rhs.unknownExprIds())
75-
.build());
69+
Sets.union(lhs.attributes(), rhs.attributes()).immutableCopy(),
70+
Sets.union(lhs.unknownExprIds(), rhs.unknownExprIds()).immutableCopy());
7671
}
7772

7873
public CelUnknownSet merge(CelUnknownSet rhs) {

0 commit comments

Comments
 (0)