aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/Eval.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
index a13a9fc184..33ce4426bb 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
@@ -111,7 +111,10 @@ public class Eval {
}
void execIf(IfStatement node) throws EvalException, InterruptedException {
- for (IfStatement.ConditionalStatements stmt : node.getThenBlocks()) {
+ ImmutableList<IfStatement.ConditionalStatements> thenBlocks = node.getThenBlocks();
+ // Avoid iterator overhead - most of the time there will be one or few "if"s.
+ for (int i = 0; i < thenBlocks.size(); i++) {
+ IfStatement.ConditionalStatements stmt = thenBlocks.get(i);
if (EvalUtils.toBoolean(stmt.getCondition().eval(env))) {
exec(stmt);
return;