aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/compiler
diff options
context:
space:
mode:
authorGravatar Vladimir Moskva <vladmos@google.com>2016-08-10 15:44:31 +0000
committerGravatar Yue Gan <yueg@google.com>2016-08-11 09:12:53 +0000
commit4994cb35f634b18a21b85fe16fbaaed4abd0a36e (patch)
tree0f117af06345a31fc1e3291c9c80a4211c9e39ab /src/main/java/com/google/devtools/build/lib/syntax/compiler
parente47a5a97b5a2ccefe64cd52306eacbba97755e7f (diff)
Substituted NoSuchVariableException with manual checks for performance purposes
-- MOS_MIGRATED_REVID=129869968
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/compiler')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/compiler/Variable.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/compiler/Variable.java b/src/main/java/com/google/devtools/build/lib/syntax/compiler/Variable.java
index 41e2e5d32d..39dbe7b987 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/compiler/Variable.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/compiler/Variable.java
@@ -15,7 +15,6 @@ package com.google.devtools.build.lib.syntax.compiler;
import com.google.devtools.build.lib.syntax.ASTNode;
import com.google.devtools.build.lib.syntax.Environment;
-import com.google.devtools.build.lib.syntax.Environment.NoSuchVariableException;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.EvalExceptionWithStackTrace;
import com.google.devtools.build.lib.syntax.compiler.DebugInfo.AstAccessors;
@@ -107,15 +106,15 @@ public abstract class Variable {
*/
public static Object lookupUnboundVariable(Environment global, String variable, ASTNode node)
throws EvalExceptionWithStackTrace {
- try {
- return global.lookup(variable);
- } catch (NoSuchVariableException e) {
+ Object value = global.lookup(variable);
+ if (value == null) {
throw new EvalExceptionWithStackTrace(
new EvalException(
node.getLocation(),
"local variable '" + variable + "' referenced before assignment"),
node);
}
+ return value;
}
}