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 7b7d9de  Trivial refactoring: avoid redundant method calls
7b7d9de is described below

commit 7b7d9ded9a8c2dd03b949bc0ec8ea573c8afe9cd
Author: Daniel Sun <[email protected]>
AuthorDate: Thu Jul 9 12:19:22 2020 +0800

    Trivial refactoring: avoid redundant method calls
---
 src/main/java/org/codehaus/groovy/control/CompilationUnit.java       | 4 +---
 src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java 
b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
index a2233bd..fdfce7f 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilationUnit.java
@@ -74,7 +74,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Queue;
 import java.util.Set;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import static java.util.stream.Collectors.toList;
@@ -664,8 +663,7 @@ public class CompilationUnit extends ProcessingUnit {
                         ? sourceUnits.stream() // no need to build AST with 
parallel stream when we just have one/no source unit
                         : sourceUnits.parallelStream();
 
-        // DON'T replace `collect(Collectors.counting())` with `count()` here, 
otherwise peek will NOT be triggered
-        
sourceUnitStream.peek(SourceUnit::buildAST).collect(Collectors.counting());
+        sourceUnitStream.forEach(SourceUnit::buildAST);
     }
 
     private void processPhaseOperations(final int phase) {
diff --git 
a/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java 
b/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
index f638cdd..c819234 100644
--- a/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
+++ b/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
@@ -75,7 +75,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 import static 
org.apache.groovy.ast.tools.ConstructorNodeUtils.getFirstIfSpecialConstructorCall;
 import static 
org.codehaus.groovy.ast.tools.GenericsUtils.correctToGenericsSpec;
@@ -1038,8 +1037,7 @@ public class JavaStubGenerator {
     }
 
     public void clean() {
-        // DON'T replace `collect(Collectors.counting())` with `count()` here, 
otherwise peek will NOT be triggered
-        
javaStubCompilationUnitSet.stream().peek(FileObject::delete).collect(Collectors.counting());
+        javaStubCompilationUnitSet.stream().forEach(FileObject::delete);
         javaStubCompilationUnitSet.clear();
     }
 

Reply via email to