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

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

commit 174b2270c6e392e8de290316d030e0784d6b90d7
Author: Daniel Sun <[email protected]>
AuthorDate: Mon Oct 5 04:17:33 2020 +0800

    GROOVY-8258: minor refactor
---
 .../apache/groovy/linq/LinqGroovyMethods.groovy    | 32 +++++++++-------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git 
a/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy
 
b/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy
index cd6b502..ff368fb 100644
--- 
a/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy
+++ 
b/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy
@@ -88,29 +88,23 @@ class LinqGroovyMethods {
                     .from($v { fromEntry.value })
         }
 
-        MethodCallExpression where =
-                callX(
-                        from,
-                        "where",
-                        closureX(
-                                params(param(ClassHelper.DYNAMIC_TYPE, 
aliasVariable.name)),
-                                stmt(linqContext.whereList[0])
-                        )
-                )
-
-        MethodCallExpression select =
-                callX(
-                        where,
-                        "select",
-                        closureX(
-                                params(param(ClassHelper.DYNAMIC_TYPE, 
aliasVariable.name)),
-                                stmt(linqContext.selectList[0])
-                        )
-                )
+        MethodCallExpression where = callXWithClosure(from, "where", 
aliasVariable.name, linqContext.whereList[0])
+        MethodCallExpression select = callXWithClosure(where, "select", 
aliasVariable.name, linqContext.selectList[0])
 
         return select
     }
 
+    private static callXWithClosure(Expression receiver, String methodName, 
String closureParamName, Expression closureCode) {
+        callX(
+                receiver,
+                methodName,
+                closureX(
+                        params(param(ClassHelper.DYNAMIC_TYPE, 
closureParamName)),
+                        stmt(closureCode)
+                )
+        )
+    }
+
     @ToString(includeNames=true)
     static class LinqContext {
         Map<VariableExpression, Expression> fromMap = new LinkedHashMap<>()

Reply via email to