aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.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/TargetUtils.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/TargetUtils.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java34
1 files changed, 7 insertions, 27 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java b/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java
index b1dd3da648..b68f90790a 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/TargetUtils.java
@@ -275,9 +275,13 @@ public final class TargetUtils {
return true;
}
- ExplicitEdgeVisitor visitor = new ExplicitEdgeVisitor(rule, label);
- AggregatingAttributeMapper.of(rule).visitLabels(visitor);
- return visitor.isExplicit();
+ for (AttributeMap.DepEdge depEdge : AggregatingAttributeMapper.of(rule).visitLabels()) {
+ if (rule.isAttributeValueExplicitlySpecified(depEdge.getAttribute())
+ && label.equals(depEdge.getLabel())) {
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -306,30 +310,6 @@ public final class TargetUtils {
};
}
- private static class ExplicitEdgeVisitor implements AttributeMap.AcceptsLabelAttribute {
- private final Label expectedLabel;
- private final Rule rule;
- private boolean isExplicit = false;
-
- public ExplicitEdgeVisitor(Rule rule, Label expected) {
- this.rule = rule;
- this.expectedLabel = expected;
- }
-
- @Override
- public void acceptLabelAttribute(Label label, Attribute attr) {
- if (isExplicit || !rule.isAttributeValueExplicitlySpecified(attr)) {
- // Nothing to do here.
- } else if (expectedLabel.equals(label)) {
- isExplicit = true;
- }
- }
-
- public boolean isExplicit() {
- return isExplicit;
- }
- }
-
/**
* Return {@link Location} for {@link Target} target, if it should not be null.
*/