You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2018/09/15 07:34:26 UTC

groovy git commit: Trivial refactoring: extract common variables

Repository: groovy
Updated Branches:
  refs/heads/master 3c11d4d24 -> 9205bb1f3


Trivial refactoring: extract common variables


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/9205bb1f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/9205bb1f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/9205bb1f

Branch: refs/heads/master
Commit: 9205bb1f3db5117a14bf295e95de90cfa4d92157
Parents: 3c11d4d
Author: Daniel Sun <su...@apache.org>
Authored: Sat Sep 15 15:34:19 2018 +0800
Committer: Daniel Sun <su...@apache.org>
Committed: Sat Sep 15 15:34:19 2018 +0800

----------------------------------------------------------------------
 .../java/org/apache/groovy/parser/antlr4/AstBuilder.java     | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/9205bb1f/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 16bda16..98526a1 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -2337,13 +2337,15 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
                     this.visitNamedPropertyArgs(ctx.namedPropertyArgs());
 
             Expression right;
-            if (mapEntryExpressionList.size() == 0) {
+            Expression firstKeyExpression;
+            int mapEntryExpressionListSize = mapEntryExpressionList.size();
+            if (mapEntryExpressionListSize == 0) {
                 // expecting list of MapEntryExpressions later so use SpreadMap to smuggle empty MapExpression to later stages
                 right = configureAST(
                         new SpreadMapExpression(configureAST(new MapExpression(), ctx.namedPropertyArgs())),
                         ctx.namedPropertyArgs());
-            } else if (mapEntryExpressionList.size() == 1 && mapEntryExpressionList.get(0).getKeyExpression() instanceof SpreadMapExpression) {
-                right = mapEntryExpressionList.get(0).getKeyExpression();
+            } else if (mapEntryExpressionListSize == 1 && (firstKeyExpression = mapEntryExpressionList.get(0).getKeyExpression()) instanceof SpreadMapExpression) {
+                right = firstKeyExpression;
             } else {
                 ListExpression listExpression =
                         configureAST(