aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/collect/nestedset
diff options
context:
space:
mode:
authorGravatar Jon Brandvein <brandjon@google.com>2017-01-20 04:23:37 +0000
committerGravatar Vladimir Moskva <vladmos@google.com>2017-01-20 12:20:55 +0000
commit3cfeeec080e8c837dbc118bc8b6005f01d30a688 (patch)
tree09bdb16a74519f0014281be9615a7a14637c9556 /src/main/java/com/google/devtools/build/lib/collect/nestedset
parentafd34e072556b1565b43ebc2ba25980f595166c4 (diff)
Refactor SkylarkNestedSet to not implement Iterable
This is not intended to be a user-visible semantic change, aside from error messages. This is to help avoid unintentional flattening of depsets, and to narrow down the number of call sites where this can occur, to help us print warning/deprecation messages. EvalUtils#toIterable will now return an ImmutableList in place of SkylarkNestedSet. This should be ok since the caller shouldn't be relying on the result being a Skylark-safe type. Code that takes Iterable because it accepts either a list or set, can instead be changed to take Object and use EvalUtils#toIterableStrict for validation. Note that NestedSet still implements Iterable, so native code can still easily and accidentally flatten sets. -- PiperOrigin-RevId: 145044023 MOS_MIGRATED_REVID=145044023
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/collect/nestedset')
-rw-r--r--src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSet.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSet.java b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSet.java
index 39265a6875..9f5b9d97c5 100644
--- a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSet.java
+++ b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSet.java
@@ -151,7 +151,7 @@ public final class NestedSet<E> implements Iterable<E> {
}
/**
- * Returns true if the set is empty.
+ * Returns true if the set is empty. Runs in O(1) time (i.e. does not flatten the set).
*/
public boolean isEmpty() {
return children == EMPTY_CHILDREN;