aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages
diff options
context:
space:
mode:
authorGravatar Eric Fellheimer <felly@google.com>2015-08-27 19:37:52 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-08-28 09:21:49 +0000
commita954fae3183ff68521dff650a405c505394a9917 (patch)
tree5d09133143f747678828dc8a718ad06a67834b14 /src/main/java/com/google/devtools/build/lib/packages
parentff938b33b2480951a87816a5bb8c7d82d993d443 (diff)
Avoid repeated copies of RuleClass attributes.
-- MOS_MIGRATED_REVID=101707604
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/RuleClass.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index 3affb169cf..ee1fce3bb8 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -916,7 +916,7 @@ public final class RuleClass {
* All attributes of this rule class (including inherited ones) ordered by
* attributeIndex value.
*/
- private final Attribute[] attributes;
+ private final ImmutableList<Attribute> attributes;
/**
* The set of implicit outputs generated by a rule, expressed as a function
@@ -1098,8 +1098,7 @@ public final class RuleClass {
this.configuredTargetFunction = configuredTargetFunction;
this.externalBindingsFunction = externalBindingsFunction;
this.ruleDefinitionEnvironment = ruleDefinitionEnvironment;
- // Do not make a defensive copy as builder does that already
- this.attributes = attributes;
+ this.attributes = ImmutableList.copyOf(attributes);
this.workspaceOnly = workspaceOnly;
this.outputsDefaultExecutable = outputsDefaultExecutable;
this.requiredConfigurationFragments = ImmutableSet.copyOf(allowedConfigurationFragments);
@@ -1186,14 +1185,14 @@ public final class RuleClass {
* not in range.
*/
Attribute getAttribute(int attrIndex) {
- return attributes[attrIndex];
+ return attributes.get(attrIndex);
}
/**
* Returns the attribute whose name is 'attrName'; fails if not found.
*/
public Attribute getAttributeByName(String attrName) {
- return attributes[getAttributeIndex(attrName)];
+ return attributes.get(getAttributeIndex(attrName));
}
/**
@@ -1202,7 +1201,7 @@ public final class RuleClass {
*/
Attribute getAttributeByNameMaybe(String attrName) {
Integer i = getAttributeIndex(attrName);
- return i == null ? null : attributes[i];
+ return i == null ? null : attributes.get(i);
}
/**
@@ -1217,7 +1216,7 @@ public final class RuleClass {
* rule, ordered by increasing index.
*/
public List<Attribute> getAttributes() {
- return ImmutableList.copyOf(attributes);
+ return attributes;
}
public PredicateWithMessage<Rule> getValidityPredicate() {