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:19 UTC

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

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);
         }
     }