diff options
author | Taras Tsugrii <ttsugrii@fb.com> | 2018-07-31 11:51:21 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-31 11:52:31 -0700 |
commit | 58f80df1378e4f8687ca6690001577f075de2038 (patch) | |
tree | 746ec0359b0019ddee94ffc7014b7e336fb3b1b7 | |
parent | 4b8d0ae907749440edb8f5f899e570d58e4d963b (diff) |
[Skylark] Cache isParamNamed computation.
When `isLegacyNamed` is `true`, `named` is considered to be `true` as well,
so instead of going through an extra indirection and computation, just use
`named` field to store combined result.
Closes #5701.
PiperOrigin-RevId: 206800781
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java | 8 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/ParamDescriptor.java | 9 |
2 files changed, 3 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java index 48c52f5791..e8df5abc0c 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java @@ -514,10 +514,6 @@ public final class FuncallExpression extends Expression { return matchingMethod; } - private static boolean isParamNamed(ParamDescriptor param) { - return param.isNamed() || param.isLegacyNamed(); - } - /** * Returns the extra interpreter arguments for the given {@link SkylarkCallable}, to be added at * the end of the argument list for the callable. @@ -581,13 +577,13 @@ public final class FuncallExpression extends Expression { "expected value of type '%s' for parameter '%s'", type.toString(), param.getName())); } - if (isParamNamed(param) && keys.contains(param.getName())) { + if (param.isNamed() && keys.contains(param.getName())) { return ArgumentListConversionResult.fromError( String.format("got multiple values for keyword argument '%s'", param.getName())); } argIndex++; } else { // No more positional arguments, or no more positional parameters. - if (isParamNamed(param) && keys.remove(param.getName())) { + if (param.isNamed() && keys.remove(param.getName())) { // Param specified by keyword argument. value = kwargs.get(param.getName()); if (!type.contains(value)) { diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ParamDescriptor.java b/src/main/java/com/google/devtools/build/lib/syntax/ParamDescriptor.java index 1bbc05b95a..dd2bb9c815 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/ParamDescriptor.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/ParamDescriptor.java @@ -29,7 +29,6 @@ public final class ParamDescriptor { private final Class<?> generic1; private final boolean noneable; private final boolean named; - private final boolean legacyNamed; private final boolean positional; // While the type can be inferred completely by the Param annotation, this tuple allows for the // type of a given parameter to be determined only once, as it is an expensive operation. @@ -54,8 +53,7 @@ public final class ParamDescriptor { this.allowedTypes = allowedTypes; this.generic1 = generic1; this.noneable = noneable; - this.named = named; - this.legacyNamed = legacyNamed; + this.named = named || legacyNamed; this.positional = positional; this.skylarkType = skylarkType; } @@ -143,11 +141,6 @@ public final class ParamDescriptor { return named; } - /** @see Param#legacyNamed() */ - public boolean isLegacyNamed() { - return legacyNamed; - } - /** @see Param#defaultValue() */ public String getDefaultValue() { return defaultValue; |