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 2017/12/26 01:17:13 UTC

[2/3] groovy git commit: Use entrySet to iterate map entries

Use entrySet to iterate map entries

(cherry picked from commit 12997ac)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: e6bccafbcbca6ec73eb24bdfa2d85f0b0c329c2a
Parents: c5256e8
Author: sunlan <su...@apache.org>
Authored: Tue Dec 26 08:09:08 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Tue Dec 26 09:17:01 2017 +0800

----------------------------------------------------------------------
 src/main/groovy/groovy/lang/SpreadMap.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e6bccafb/src/main/groovy/groovy/lang/SpreadMap.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/SpreadMap.java b/src/main/groovy/groovy/lang/SpreadMap.java
index 7ba9e4f..0fc6542 100644
--- a/src/main/groovy/groovy/lang/SpreadMap.java
+++ b/src/main/groovy/groovy/lang/SpreadMap.java
@@ -68,6 +68,7 @@ public class SpreadMap extends HashMap {
                                    + t + ") cannot be put in this spreadMap.");
     }
 
+    @Override
     public boolean equals(Object that) {
         if (that instanceof SpreadMap) {
             return equals((SpreadMap) that);
@@ -79,8 +80,10 @@ public class SpreadMap extends HashMap {
         if (that == null) return false;        
 
         if (size() == that.size()) {
-            for (Object key : keySet()) {
-                if (!DefaultTypeTransformation.compareEqual(get(key), that.get(key))) {
+            for (Object e : entrySet()) {
+                Map.Entry entry = (Map.Entry) e;
+                Object key = entry.getKey();
+                if (!DefaultTypeTransformation.compareEqual(entry.getValue(), that.get(key))) {
                     return false;
                 }
             }
@@ -89,6 +92,7 @@ public class SpreadMap extends HashMap {
         return false;
     }
 
+    @Override
     public int hashCode() {
         if (hashCode == 0) {
             for (Object key : keySet()) {