Skip to content

Commit

Permalink
Avoid unnecessary iteration on action inputs.
Browse files Browse the repository at this point in the history
Closes #16118.

PiperOrigin-RevId: 468429355
Change-Id: I3b32a28ce3e7c6711fdc15839e5a88fad812184c
  • Loading branch information
coeuvre authored and copybara-github committed Aug 18, 2022
1 parent c89cea0 commit 42ff95a
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,13 +83,13 @@ public void ensureInputsPresent(
Map<Digest, Message> additionalInputs,
boolean force)
throws IOException, InterruptedException {
ImmutableSet<Digest> allDigests =
ImmutableSet.<Digest>builder()
.addAll(merkleTree.getAllDigests())
.addAll(additionalInputs.keySet())
.build();
Iterable<Digest> merkleTreeAllDigests;
try (SilentCloseable s = Profiler.instance().profile("merkleTree.getAllDigests()")) {
merkleTreeAllDigests = merkleTree.getAllDigests();
}
Iterable<Digest> allDigests = Iterables.concat(merkleTreeAllDigests, additionalInputs.keySet());

if (allDigests.isEmpty()) {
if (Iterables.isEmpty(allDigests)) {
return;
}

Expand Down

0 comments on commit 42ff95a

Please sign in to comment.