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 2020/11/28 15:03:39 UTC

[groovy] branch master updated: Avoid constructing long text as possible as we could

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new b596f2f  Avoid constructing long text as possible as we could
b596f2f is described below

commit b596f2fd6eb4bee98a268e1e7436fbe025662eaf
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Nov 28 23:03:17 2020 +0800

    Avoid constructing long text as possible as we could
---
 .../apache/groovy/ginq/provider/collection/GinqAstWalker.groovy    | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy
index d157f9b..ddb17f7 100644
--- a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy
+++ b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy
@@ -478,7 +478,7 @@ class GinqAstWalker implements GinqAstVisitor<Expression>, SyntaxErrorReportable
         List<Expression> nameExpressionList = new ArrayList<>(expressionListSize)
         for (Expression e : expressionList) {
             Expression elementExpression = e
-            Expression nameExpression = new ConstantExpression(e.text)
+            Expression nameExpression = null
 
             if (e instanceof CastExpression) {
                 elementExpression = e.expression
@@ -492,6 +492,11 @@ class GinqAstWalker implements GinqAstVisitor<Expression>, SyntaxErrorReportable
                     nameExpression = e.property
                 }
             }
+
+            if (null == nameExpression) {
+                nameExpression = new ConstantExpression(e.text)
+            }
+
             elementExpressionList << elementExpression
             nameExpressionList << nameExpression
         }