Skip to content

Commit 42ff95a

Browse files
coeuvrecopybara-github
authored andcommitted
Avoid unnecessary iteration on action inputs.
Closes bazelbuild#16118. PiperOrigin-RevId: 468429355 Change-Id: I3b32a28ce3e7c6711fdc15839e5a88fad812184c
1 parent c89cea0 commit 42ff95a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.common.base.Throwables;
2929
import com.google.common.collect.ImmutableList;
3030
import com.google.common.collect.ImmutableSet;
31+
import com.google.common.collect.Iterables;
3132
import com.google.common.util.concurrent.ListenableFuture;
3233
import com.google.devtools.build.lib.profiler.Profiler;
3334
import com.google.devtools.build.lib.profiler.SilentCloseable;
@@ -82,13 +83,13 @@ public void ensureInputsPresent(
8283
Map<Digest, Message> additionalInputs,
8384
boolean force)
8485
throws IOException, InterruptedException {
85-
ImmutableSet<Digest> allDigests =
86-
ImmutableSet.<Digest>builder()
87-
.addAll(merkleTree.getAllDigests())
88-
.addAll(additionalInputs.keySet())
89-
.build();
86+
Iterable<Digest> merkleTreeAllDigests;
87+
try (SilentCloseable s = Profiler.instance().profile("merkleTree.getAllDigests()")) {
88+
merkleTreeAllDigests = merkleTree.getAllDigests();
89+
}
90+
Iterable<Digest> allDigests = Iterables.concat(merkleTreeAllDigests, additionalInputs.keySet());
9091

91-
if (allDigests.isEmpty()) {
92+
if (Iterables.isEmpty(allDigests)) {
9293
return;
9394
}
9495

0 commit comments

Comments
 (0)