groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 01/02: Trivial refactoring: The loop could be replaced with `Collection.removeIf`
Date Fri, 23 Aug 2019 10:40:19 GMT
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 <sunlan@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);
         }
     }


Mime
View raw message