Speed up QName.intern() a bit 57/81057/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Mar 2019 22:17:37 +0000 (23:17 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Mar 2019 22:17:37 +0000 (23:17 +0100)
In case we end up interning the localName, we should use the private
constructor to side-step re-validating localName.

Change-Id: I54029d15c93ae32f5c857e890c8313a9f62f58f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/QName.java

index e8851f7c055e6e2675660711c137e7372fdc1384..768cc3eba91c6388a31e9eac341aff36088c7ff3 100644 (file)
@@ -276,7 +276,7 @@ public final class QName implements Immutable, Serializable, Comparable<QName>,
         // Identity comparison is here on purpose, as we are deciding whether to potentially store 'qname' into the
         // interner. It is important that it does not hold user-supplied reference (such a String instance from
         // parsing of an XML document).
-        final QName template = cacheMod == module ? this : QName.create(cacheMod, localName.intern());
+        final QName template = cacheMod == module ? this : new QName(cacheMod, localName.intern());
 
         return INTERNER.intern(template);
     }