diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java index d38c39206b3776..2414c9f676875b 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java @@ -28,6 +28,7 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.common.util.concurrent.ListenableFuture; import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.SilentCloseable; @@ -82,13 +83,13 @@ public void ensureInputsPresent( Map additionalInputs, boolean force) throws IOException, InterruptedException { - ImmutableSet allDigests = - ImmutableSet.builder() - .addAll(merkleTree.getAllDigests()) - .addAll(additionalInputs.keySet()) - .build(); + Iterable merkleTreeAllDigests; + try (SilentCloseable s = Profiler.instance().profile("merkleTree.getAllDigests()")) { + merkleTreeAllDigests = merkleTree.getAllDigests(); + } + Iterable allDigests = Iterables.concat(merkleTreeAllDigests, additionalInputs.keySet()); - if (allDigests.isEmpty()) { + if (Iterables.isEmpty(allDigests)) { return; }