groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [2/3] groovy git commit: Use entrySet to iterate map entries
Date Tue, 26 Dec 2017 01:21:27 GMT
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/060140b4
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/060140b4
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/060140b4

Branch: refs/heads/GROOVY_2_5_X
Commit: 060140b41e119e4fc4240599deb5cdf184fe726d
Parents: 3dbfc13
Author: sunlan <sunlan@apache.org>
Authored: Tue Dec 26 08:09:08 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Dec 26 09:21:16 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/060140b4/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()) {


Mime
View raw message