Improve QNameModule.equals() performance 29/9329/1
authorRobert Varga <rovarga@cisco.com>
Fri, 25 Jul 2014 19:09:23 +0000 (21:09 +0200)
committerRobert Varga <rovarga@cisco.com>
Fri, 25 Jul 2014 19:10:31 +0000 (21:10 +0200)
URI.equals() is slower than Date.equals(), so let's compare revision
first, hopefully eliding the costlier equality check.

Change-Id: Ia42e13917432c696c756758c95c3f6a668396ff9
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/QNameModule.java

index 4afa8c7c98f007d24110ea6f256360f702ea79fa..a45c91b923b13c8ddb26fb5e81ad16d12d54f9cc 100644 (file)
@@ -98,18 +98,18 @@ public final class QNameModule implements Immutable, Serializable {
             return false;
         }
         final QNameModule other = (QNameModule) obj;
-        if (namespace == null) {
-            if (other.namespace != null) {
+        if (revision == null) {
+            if (other.revision != null) {
                 return false;
             }
-        } else if (!namespace.equals(other.namespace)) {
+        } else if (!revision.equals(other.revision)) {
             return false;
         }
-        if (revision == null) {
-            if (other.revision != null) {
+        if (namespace == null) {
+            if (other.namespace != null) {
                 return false;
             }
-        } else if (!revision.equals(other.revision)) {
+        } else if (!namespace.equals(other.namespace)) {
             return false;
         }
         return true;