Skip to content

Commit

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

PiperOrigin-RevId: 468429355
Change-Id: I3b32a28ce3e7c6711fdc15839e5a88fad812184c

Co-authored-by: Chi Wang <chiwang@google.com>
  • Loading branch information
ShreeM01 and coeuvre authored Oct 12, 2022
1 parent 77f0233 commit 4657931
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 4657931

Please sign in to comment.