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 2019/08/23 10:40:18 UTC

[groovy] branch master updated (5381eee -> a4bffdc)

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

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


    from 5381eee  GROOVY-9234: Bump build-scan gradle plugin to 2.4.1
     new df789a5  Trivial refactoring: The loop could be replaced with `Collection.removeIf`
     new a4bffdc  Trivial refactoring: Simplify code with `Map.computeIfAbsent`

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../groovy/transform/ASTTransformationVisitor.java       | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)


[groovy] 02/02: Trivial refactoring: Simplify code with `Map.computeIfAbsent`

Posted by su...@apache.org.
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

commit a4bffdc7818e1606ce8c8d550984e1a3c0bdfab8
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Aug 23 18:34:46 2019 +0800

    Trivial refactoring: Simplify code with `Map.computeIfAbsent`
---
 .../org/codehaus/groovy/transform/ASTTransformationVisitor.java     | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
index 8d0a6bc..abcd593 100644
--- a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
@@ -126,11 +126,7 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
             transforms = new HashMap<ASTNode, List<ASTTransformation>>();
             for (Map.Entry<Class<? extends ASTTransformation>, Set<ASTNode>> entry : baseTransforms.entrySet()) {
                 for (ASTNode node : entry.getValue()) {
-                    List<ASTTransformation> list = transforms.get(node);
-                    if (list == null)  {
-                        list = new ArrayList<ASTTransformation>();
-                        transforms.put(node, list);
-                    }
+                    List<ASTTransformation> list = transforms.computeIfAbsent(node, k -> new ArrayList<>());
                     list.add(transformInstances.get(entry.getKey()));
                 }
             }


[groovy] 01/02: Trivial refactoring: The loop could be replaced with `Collection.removeIf`

Posted by su...@apache.org.
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

commit df789a55f35cf53066c2360b0244944ed1d002bf
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Aug 23 18:32:00 2019 +0800

    Trivial refactoring: The loop could be replaced with `Collection.removeIf`
---
 .../codehaus/groovy/transform/ASTTransformationVisitor.java    | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
index c356811..8d0a6bc 100644
--- a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
@@ -319,14 +319,8 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
             }
             addPhaseOperationsForGlobalTransforms(context.getCompilationUnit(), transformNames, isFirstScan);
         } else {
-            Iterator<Map.Entry<String, URL>> it = transformNames.entrySet().iterator();
-            while(it.hasNext()) {
-                Map.Entry<String, URL> entry = it.next();
-                if(!context.getGlobalTransformNames().add(entry.getKey())) {
-                    // phase operations for this transform class have already been added before, so remove from current scan cycle
-                    it.remove(); 
-                }
-            }
+            // phase operations for this transform class have already been added before, so remove from current scan cycle
+            transformNames.entrySet().removeIf(entry -> !context.getGlobalTransformNames().add(entry.getKey()));
             addPhaseOperationsForGlobalTransforms(context.getCompilationUnit(), transformNames, isFirstScan);
         }
     }