aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages/BuildType.java
diff options
context:
space:
mode:
authorGravatar nharmata <nharmata@google.com>2017-04-04 19:09:15 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-04-05 15:18:52 +0200
commitd705c98773afd3d08f7c04f71263b23f3dbc98f7 (patch)
treeee9c1a3b0d45b407769ca3a5b9d6a1a98d3138b4 /src/main/java/com/google/devtools/build/lib/packages/BuildType.java
parente5538add58a952c1ef660e417f3f38dabf73b768 (diff)
Rephrase AbstractAttributeMapper#visitLabels such that we can avoid creating a temporary Type.LabelVisitor instance per Attribute being visited. Instead, we can now create one temporary object per visitation. Getting rid of this dimension of scaling reduces the amount of garbage created.
RELNOTES: None PiperOrigin-RevId: 152161836
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages/BuildType.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/BuildType.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/BuildType.java b/src/main/java/com/google/devtools/build/lib/packages/BuildType.java
index 263fe63e79..5df9d83625 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/BuildType.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/BuildType.java
@@ -30,6 +30,7 @@ import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.syntax.Type.ConversionException;
import com.google.devtools.build.lib.syntax.Type.DictType;
import com.google.devtools.build.lib.syntax.Type.LabelClass;
+import com.google.devtools.build.lib.syntax.Type.LabelVisitor;
import com.google.devtools.build.lib.syntax.Type.ListType;
import java.util.ArrayList;
import java.util.Collections;
@@ -103,7 +104,7 @@ public final class BuildType {
}
@Override
- public void visitLabels(LabelVisitor visitor, Object value) {
+ public <T> void visitLabels(LabelVisitor<T> visitor, Object value, T context) {
}
@Override
@@ -200,9 +201,10 @@ public final class BuildType {
}
@Override
- public void visitLabels(LabelVisitor visitor, Object value) throws InterruptedException {
+ public <T> void visitLabels(LabelVisitor<T> visitor, Object value, T context)
+ throws InterruptedException {
for (Label label : cast(value).getLabels()) {
- visitor.visit(label);
+ visitor.visit(label, context);
}
}
}
@@ -225,8 +227,9 @@ public final class BuildType {
}
@Override
- public void visitLabels(LabelVisitor visitor, Object value) throws InterruptedException {
- visitor.visit(cast(value));
+ public <T> void visitLabels(LabelVisitor<T> visitor, Object value, T context)
+ throws InterruptedException {
+ visitor.visit(cast(value), context);
}
@Override
@@ -345,7 +348,7 @@ public final class BuildType {
}
@Override
- public void visitLabels(LabelVisitor visitor, Object value) {
+ public <T> void visitLabels(LabelVisitor<T> visitor, Object value, T context) {
}
@Override
@@ -384,7 +387,7 @@ public final class BuildType {
}
@Override
- public void visitLabels(LabelVisitor visitor, Object value) {
+ public <T> void visitLabels(LabelVisitor<T> visitor, Object value, T context) {
}
@Override
@@ -410,8 +413,9 @@ public final class BuildType {
}
@Override
- public void visitLabels(LabelVisitor visitor, Object value) throws InterruptedException {
- visitor.visit(cast(value));
+ public <T> void visitLabels(LabelVisitor<T> visitor, Object value, T context)
+ throws InterruptedException {
+ visitor.visit(cast(value), context);
}
@Override
@@ -676,7 +680,7 @@ public final class BuildType {
}
@Override
- public void visitLabels(LabelVisitor visitor, Object value) {
+ public <T> void visitLabels(LabelVisitor<T> visitor, Object value, T context) {
}
@Override