Add a quick identity check for map comparison 63/21763/2
authorRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 13:14:06 +0000 (15:14 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 17:19:13 +0000 (19:19 +0200)
This should speed up the case of copied values. Also add a TODO for
future improvement.

Change-Id: Ie5122bd9b4941f05b6a94d30ecacbaab8dab2923
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifier.java

index 60e2f5c8d3fdb917e90c7ea1610b531829f46b16..afbf3c1fe3688d498176524ce415bbcc87c81e3e 100644 (file)
@@ -507,6 +507,11 @@ public abstract class YangInstanceIdentifier extends IterablePathArguments imple
             }
 
             final Map<QName, Object> otherKeyValues = ((NodeIdentifierWithPredicates) obj).keyValues;
+
+            // TODO: benchmark to see if just calling equals() on the two maps is not faster
+            if (keyValues == otherKeyValues) {
+                return true;
+            }
             if (keyValues.size() != otherKeyValues.size()) {
                 return false;
             }