Skip to content

Commit

Permalink
Remove CompositeRunfilesSupplier.of() and CompositeRunfilesSupplier.f…
Browse files Browse the repository at this point in the history
…romSuppliers().

These methods are not called from anywhere.

RELNOTES: None.
PiperOrigin-RevId: 607305445
Change-Id: I4feee8fddaab68bb594f0165af51455e65b50697
  • Loading branch information
lberki authored and copybara-github committed Feb 15, 2024
1 parent d087622 commit b8190c9
Showing 1 changed file with 0 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@

package com.google.devtools.build.lib.actions;

import static com.google.common.collect.ImmutableList.toImmutableList;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/** A {@link RunfilesSupplier} implementation for composing multiple instances. */
public final class CompositeRunfilesSupplier implements RunfilesSupplier {
Expand All @@ -43,45 +36,6 @@ public static RunfilesSupplier fromRunfilesTrees(Collection<RunfilesTree> runfil
return new CompositeRunfilesSupplier(ImmutableList.copyOf(runfilesTrees));
}

/**
* Create a composite {@link RunfilesSupplier} from a collection of suppliers. Suppliers earlier
* in the collection take precedence over later suppliers.
*/
public static RunfilesSupplier fromSuppliers(Collection<RunfilesSupplier> suppliers) {
ImmutableList<RunfilesSupplier> nonEmptySuppliers =
suppliers.stream()
.filter((s) -> s != EmptyRunfilesSupplier.INSTANCE)
.collect(toImmutableList());

if (nonEmptySuppliers.isEmpty()) {
return EmptyRunfilesSupplier.INSTANCE;
}

if (nonEmptySuppliers.size() == 1) {
return Iterables.getOnlyElement(nonEmptySuppliers);
}

Set<PathFragment> execPaths = new HashSet<>();
List<RunfilesTree> trees = new ArrayList<>();

for (RunfilesSupplier supplier : nonEmptySuppliers) {
for (RunfilesTree tree : supplier.getRunfilesTrees()) {
if (execPaths.add(tree.getExecPath())) {
trees.add(tree);
}
}
}

return new CompositeRunfilesSupplier(ImmutableList.copyOf(trees));
}

/**
* Convenience method for creating a composite {@link RunfilesSupplier} from two other suppliers.
*/
public static RunfilesSupplier of(RunfilesSupplier supplier1, RunfilesSupplier supplier2) {
return fromSuppliers(ImmutableList.of(supplier1, supplier2));
}

/**
* Create an instance combining all of {@code suppliers}, with earlier elements taking precedence.
*/
Expand Down

0 comments on commit b8190c9

Please sign in to comment.