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 e7ad83d  Remove redundant method call and improve resolving determinacy
e7ad83d is described below

commit e7ad83dec75fa5728318ef76009730c94dae5807
Author: Daniel Sun <sun...@apache.org>
AuthorDate: Wed Jan 16 22:46:02 2019 +0800

    Remove redundant method call and improve resolving determinacy
---
 .../java/org/codehaus/groovy/ast/CompileUnit.java  | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/CompileUnit.java 
b/src/main/java/org/codehaus/groovy/ast/CompileUnit.java
index 137d079..79f76f6 100644
--- a/src/main/java/org/codehaus/groovy/ast/CompileUnit.java
+++ b/src/main/java/org/codehaus/groovy/ast/CompileUnit.java
@@ -30,8 +30,8 @@ import org.objectweb.asm.Opcodes;
 import java.security.CodeSource;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -45,15 +45,15 @@ import java.util.Map;
  */
 public class CompileUnit implements NodeMetaDataHandler {
 
-    private final List<ModuleNode> modules = new ArrayList<ModuleNode>();
-    private final Map<String, ClassNode> classes = new HashMap<String, 
ClassNode>();
+    private final List<ModuleNode> modules = new ArrayList<>();
+    private final Map<String, ClassNode> classes = new LinkedHashMap<>();
     private final CompilerConfiguration config;
     private final GroovyClassLoader classLoader;
     private final CodeSource codeSource;
-    private final Map<String, ClassNode> classesToCompile = new 
HashMap<String, ClassNode>();
-    private final Map<String, SourceUnit> classNameToSource = new 
HashMap<String, SourceUnit>();
-    private final Map<String, InnerClassNode> generatedInnerClasses = new 
HashMap();
-    private final Map<String, ConstructedOuterNestedClassNode> 
classesToResolve = new HashMap<>();
+    private final Map<String, ClassNode> classesToCompile = new 
LinkedHashMap<>();
+    private final Map<String, SourceUnit> classNameToSource = new 
LinkedHashMap<>();
+    private final Map<String, InnerClassNode> generatedInnerClasses = new 
LinkedHashMap<>();
+    private final Map<String, ConstructedOuterNestedClassNode> 
classesToResolve = new LinkedHashMap<>();
     private Map metaDataMap = null;
 
     public CompileUnit(GroovyClassLoader classLoader, CompilerConfiguration 
config) {
@@ -153,8 +153,8 @@ public class CompileUnit implements NodeMetaDataHandler {
         }
         classes.put(name, node);
 
-        if (classesToCompile.containsKey(name)) {
-            ClassNode cn = classesToCompile.get(name);
+        ClassNode cn = classesToCompile.get(name);
+        if (null != cn) {
             cn.setRedirect(node);
             classesToCompile.remove(name);
         }
@@ -166,8 +166,9 @@ public class CompileUnit implements NodeMetaDataHandler {
      * at the end of a parse step no node should be be left.
      */
     public void addClassNodeToCompile(ClassNode node, SourceUnit location) {
-        classesToCompile.put(node.getName(), node);
-        classNameToSource.put(node.getName(), location);
+        String nodeName = node.getName();
+        classesToCompile.put(nodeName, node);
+        classNameToSource.put(nodeName, location);
     }
 
     public SourceUnit getScriptSourceLocation(String className) {

Reply via email to