diff options
author | janakr <janakr@google.com> | 2018-08-09 15:59:24 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-09 16:01:37 -0700 |
commit | d0a3c5eb67320906e4b937df5434f0e673cb6dce (patch) | |
tree | bd53ecfb3e65235f83e18d2d56382fb1468d1e2c /src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java | |
parent | 39974a43abdd32e3a1acbc7da945b08da9983e4e (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/AbstractAttributeMapper.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java index fc587e090b..384ce097b9 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/AbstractAttributeMapper.java @@ -19,6 +19,9 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.packages.BuildType.SelectorList; import com.google.devtools.build.lib.syntax.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import javax.annotation.Nullable; /** @@ -162,16 +165,15 @@ public abstract class AbstractAttributeMapper implements AttributeMap { } @Override - public void visitLabels(final AcceptsLabelAttribute observer) throws InterruptedException { - Type.LabelVisitor<Attribute> visitor = new Type.LabelVisitor<Attribute>() { - @Override - public void visit(@Nullable Label label, Attribute attribute) throws InterruptedException { - if (label != null) { - Label absoluteLabel = ruleLabel.resolveRepositoryRelative(label); - observer.acceptLabelAttribute(absoluteLabel, attribute); - } - } - }; + public Collection<DepEdge> visitLabels() throws InterruptedException { + List<DepEdge> edges = new ArrayList<>(); + Type.LabelVisitor<Attribute> visitor = + (label, attribute) -> { + if (label != null) { + Label absoluteLabel = ruleLabel.resolveRepositoryRelative(label); + edges.add(AttributeMap.DepEdge.create(absoluteLabel, attribute)); + } + }; for (Attribute attribute : ruleClass.getAttributes()) { Type<?> type = attribute.getType(); // TODO(bazel-team): clean up the typing / visitation interface so we don't have to @@ -181,6 +183,7 @@ public abstract class AbstractAttributeMapper implements AttributeMap { visitLabels(attribute, visitor); } } + return edges; } /** Visits all labels reachable from the given attribute. */ |