aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages/Rule.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-08-09 15:59:24 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-09 16:01:37 -0700
commitd0a3c5eb67320906e4b937df5434f0e673cb6dce (patch)
treebd53ecfb3e65235f83e18d2d56382fb1468d1e2c /src/main/java/com/google/devtools/build/lib/packages/Rule.java
parent39974a43abdd32e3a1acbc7da945b08da9983e4e (diff)
Batch all DependencyResolver#getTarget calls. This leads to some duplicate iteration, but that should be cheap, while requesting packages sequentially can hurt...
PiperOrigin-RevId: 208126130
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages/Rule.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/Rule.java38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Rule.java b/src/main/java/com/google/devtools/build/lib/packages/Rule.java
index 37c8767a1e..94fbaafe54 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Rule.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Rule.java
@@ -406,12 +406,11 @@ public final class Rule implements Target, DependencyFilter.AttributeInfoProvide
/** Returns a new List instance containing all direct dependencies (all types). */
public Collection<Label> getLabels() throws InterruptedException {
final List<Label> labels = Lists.newArrayList();
- AggregatingAttributeMapper.of(this).visitLabels(new AttributeMap.AcceptsLabelAttribute() {
- @Override
- public void acceptLabelAttribute(Label label, Attribute attribute) {
- labels.add(label);
- }
- });
+ AggregatingAttributeMapper.of(this)
+ .visitLabels()
+ .stream()
+ .map(AttributeMap.DepEdge::getLabel)
+ .forEach(labels::add);
return labels;
}
@@ -444,14 +443,11 @@ public final class Rule implements Target, DependencyFilter.AttributeInfoProvide
// TODO(bazel-team): move this to AttributeMap, too. Just like visitLabels, which labels should
// be visited may depend on the calling context. We shouldn't implicitly decide this for
// the caller.
- AggregatingAttributeMapper.of(this).visitLabels(new AttributeMap.AcceptsLabelAttribute() {
- @Override
- public void acceptLabelAttribute(Label label, Attribute attribute) {
- if (predicate.apply(Rule.this, attribute)) {
- transitions.put(attribute, label);
- }
- }
- });
+ AggregatingAttributeMapper.of(this)
+ .visitLabels()
+ .stream()
+ .filter(depEdge -> predicate.apply(Rule.this, depEdge.getAttribute()))
+ .forEach(depEdge -> transitions.put(depEdge.getAttribute(), depEdge.getLabel()));
return transitions;
}
@@ -706,16 +702,10 @@ public final class Rule implements Target, DependencyFilter.AttributeInfoProvide
// the introduction of this code is #2210848 (NullPointerException in
// Package.checkForConflicts() ).
void checkForNullLabels() throws InterruptedException {
- AggregatingAttributeMapper.of(this).visitLabels(
- new AttributeMap.AcceptsLabelAttribute() {
- @Override
- public void acceptLabelAttribute(Label labelToCheck, Attribute attribute) {
- checkForNullLabel(labelToCheck, attribute);
- }
- });
- for (OutputFile outputFile : getOutputFiles()) {
- checkForNullLabel(outputFile.getLabel(), "output file");
- }
+ AggregatingAttributeMapper.of(this)
+ .visitLabels()
+ .forEach(depEdge -> checkForNullLabel(depEdge.getLabel(), depEdge.getAttribute()));
+ getOutputFiles().forEach(outputFile -> checkForNullLabel(outputFile.getLabel(), "output file"));
}
/**