Skip to content

Commit

Permalink
Infrastructure: Add toList() calls
Browse files Browse the repository at this point in the history
This is in preparation for making NestedSet *not* implement Iterable
anymore.

PiperOrigin-RevId: 285934422
  • Loading branch information
ulfjack authored and copybara-github committed Dec 17, 2019
1 parent f44f5c8 commit 7a05289
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public NestedSet<Artifact> getExtraMiddlemen() {
public NestedSet<Artifact> getArtifacts() {
NestedSetBuilder<Artifact> allArtifacts = NestedSetBuilder.stableOrder();
allArtifacts.addTransitive(unconditionalArtifacts);
for (PruningManifest manifest : getPruningManifests()) {
for (PruningManifest manifest : getPruningManifests().toList()) {
allArtifacts.addTransitive(manifest.getCandidateRunfiles());
}
return allArtifacts.build();
Expand All @@ -372,8 +372,8 @@ public NestedSet<SymlinkEntry> getSymlinks() {
public NestedSet<String> getEmptyFilenames() {
Set<PathFragment> manifestKeys =
Streams.concat(
Streams.stream(symlinks).map(SymlinkEntry::getPath),
Streams.stream(getArtifacts()).map(Artifact::getRootRelativePath))
symlinks.toList().stream().map(SymlinkEntry::getPath),
getArtifacts().toList().stream().map(Artifact::getRootRelativePath))
.collect(ImmutableSet.toImmutableSet());
Iterable<PathFragment> emptyKeys = emptyFilesSupplier.getExtraPaths(manifestKeys);
return NestedSetBuilder.<String>stableOrder()
Expand Down Expand Up @@ -461,15 +461,15 @@ public Map<PathFragment, Artifact> getRunfilesInputs(EventHandler eventHandler,
ConflictChecker checker = new ConflictChecker(conflictPolicy, eventHandler, location);
Map<PathFragment, Artifact> manifest = getSymlinksAsMap(checker);
// Add unconditional artifacts (committed to inclusion on construction of runfiles).
for (Artifact artifact : getUnconditionalArtifacts()) {
for (Artifact artifact : getUnconditionalArtifacts().toList()) {
checker.put(manifest, artifact.getRootRelativePath(), artifact);
}

// Add conditional artifacts (only included if they appear in a pruning manifest).
for (Runfiles.PruningManifest pruningManifest : getPruningManifests()) {
for (Runfiles.PruningManifest pruningManifest : getPruningManifests().toList()) {
// This map helps us convert from source tree root-relative paths back to artifacts.
Map<String, Artifact> allowedRunfiles = new HashMap<>();
for (Artifact artifact : pruningManifest.getCandidateRunfiles()) {
for (Artifact artifact : pruningManifest.getCandidateRunfiles().toList()) {
allowedRunfiles.put(artifact.getRootRelativePath().getPathString(), artifact);
}
try (BufferedReader reader = new BufferedReader(
Expand Down Expand Up @@ -617,7 +617,7 @@ public Map<PathFragment, Artifact> asMapWithoutRootSymlinks() {
// If multiple artifacts have the same root-relative path, the last one in the list will win.
// That is because the runfiles tree cannot contain the same artifact for different
// configurations, because it only uses root-relative paths.
for (Artifact artifact : unconditionalArtifacts) {
for (Artifact artifact : unconditionalArtifacts.toList()) {
result.put(artifact.getRootRelativePath(), artifact);
}
return result;
Expand Down Expand Up @@ -673,14 +673,14 @@ public boolean isEmpty() {
*
* @param entrySet Sequence of entries to add.
* @param checker If not null, check for conflicts with this checker, otherwise silently allow
* entries to overwrite previous entries.
* entries to overwrite previous entries.
* @return Map<PathFragment, Artifact> Map of runfile entries.
*/
private static Map<PathFragment, Artifact> entriesToMap(
Iterable<SymlinkEntry> entrySet, @Nullable ConflictChecker checker) {
NestedSet<SymlinkEntry> entrySet, @Nullable ConflictChecker checker) {
checker = (checker != null) ? checker : ConflictChecker.IGNORE_CHECKER;
Map<PathFragment, Artifact> map = new LinkedHashMap<>();
for (SymlinkEntry entry : entrySet) {
for (SymlinkEntry entry : entrySet.toList()) {
checker.put(map, entry.getPath(), entry.getArtifact());
}
return map;
Expand Down Expand Up @@ -873,8 +873,7 @@ public Builder addArtifacts(Iterable<Artifact> artifacts) {
public Builder addArtifacts(NestedSet<Artifact> artifacts) {
// Do not delete this method, or else addArtifacts(Iterable) calls with a NestedSet argument
// will not be flagged.
Iterable<Artifact> it = artifacts;
addArtifacts(it);
addArtifacts(artifacts.toList());
return this;
}

Expand Down Expand Up @@ -1218,12 +1217,12 @@ public void fingerprint(Fingerprint fp) {
fp.addPath(rootSymlink.getValue().getExecPath());
}

for (Artifact artifact : getArtifacts()) {
for (Artifact artifact : getArtifacts().toList()) {
fp.addPath(artifact.getRootRelativePath());
fp.addPath(artifact.getExecPath());
}

for (String name : getEmptyFilenames()) {
for (String name : getEmptyFilenames().toList()) {
fp.addString(name);
}
}
Expand Down

0 comments on commit 7a05289

Please sign in to comment.