diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSet.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSet.java | 14 |
1 files changed, 12 insertions, 2 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 89db4ecafc..b9e43089c0 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 @@ -37,11 +37,11 @@ import javax.annotation.Nullable; public final class NestedSet<E> implements Iterable<E> { private final Order order; - private final Object children; + final Object children; private byte[] memo; private static final byte[] LEAF_MEMO = {}; - private static final Object[] EMPTY_CHILDREN = {}; + static final Object[] EMPTY_CHILDREN = {}; /** * Construct an empty NestedSet. Should only be called by Order's class initializer. @@ -134,6 +134,16 @@ public final class NestedSet<E> implements Iterable<E> { } } + // Only used by deserialization + NestedSet(Order order, Object children) { + this.order = order; + this.children = children; + boolean hasChildren = + children instanceof Object[] + && (Arrays.stream((Object[]) children).anyMatch(child -> child instanceof Object[])); + this.memo = hasChildren ? null : LEAF_MEMO; + } + /** * Returns the ordering of this nested set. */ |