groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cchamp...@apache.org
Subject [3/9] groovy git commit: Perform direct lookup in maps
Date Wed, 23 May 2018 19:28:29 GMT
Perform direct lookup in maps

Why the h... we were iterating over the map to check each entry
is beyond my understanding.


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8ac1cd61
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8ac1cd61
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8ac1cd61

Branch: refs/heads/GROOVY_2_5_X
Commit: 8ac1cd61c7323a07b7aa150e71c4299207f072c0
Parents: 71cb757
Author: Cedric Champeau <cchampeau@apache.org>
Authored: Wed May 23 09:49:38 2018 +0200
Committer: Cedric Champeau <cchampeau@apache.org>
Committed: Wed May 23 21:23:23 2018 +0200

----------------------------------------------------------------------
 .../groovy/tools/groovydoc/SimpleGroovyRootDoc.java      | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8ac1cd61/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
index 6bb4940..661ff92 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyRootDoc.java
@@ -50,10 +50,13 @@ public class SimpleGroovyRootDoc extends SimpleGroovyDoc implements GroovyRootDo
     }
 
     public GroovyClassDoc classNamed(GroovyClassDoc groovyClassDoc, String name) {
+        GroovyClassDoc doc = classDocs.get(name);
+        if (doc != null) {
+            return doc;
+        }
         // look for full match or match excluding package
         for (Map.Entry<String, GroovyClassDoc> entry : classDocs.entrySet()) {
             String key = entry.getKey();
-            if (key.equals(name)) return entry.getValue();
             int lastSlashIdx = key.lastIndexOf('/');
             if (lastSlashIdx > 0) {
                 String shortKey = key.substring(lastSlashIdx + 1);
@@ -71,11 +74,7 @@ public class SimpleGroovyRootDoc extends SimpleGroovyDoc implements GroovyRootDo
     }
 
     public GroovyClassDoc classNamedExact(String name) {
-        for (Map.Entry<String, GroovyClassDoc> entry : classDocs.entrySet()) {
-            String key = entry.getKey();
-            if (key.equals(name)) return entry.getValue();
-        }
-        return null;
+        return classDocs.get(name);
     }
 
     public void setDescription(String description) {


Mime
View raw message