Optimize SchemaContextUtil.findParentModule() 35/26535/2
authorRobert Varga <rovarga@cisco.com>
Fri, 4 Sep 2015 17:48:47 +0000 (19:48 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 7 Sep 2015 08:16:43 +0000 (08:16 +0000)
SchemaPath exposes getLastComponent(), which gives us efficient access
to the last QName in the path. Use it instead of forcing object
instantiation.

Change-Id: Ibdfb41fdb130aff8758f5cf94b262e0be854d77e
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java

index 2d21a0ec40a2c0ded9825c76fa14527e575862a6..24cc393f4a91549d4638c16df0ee0965cdd51d95 100644 (file)
@@ -221,7 +221,7 @@ public final class SchemaContextUtil {
         Preconditions.checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not "
                 + "set properly (Schema Path is NULL)");
 
-        final QName qname = Iterables.getFirst(schemaNode.getPath().getPathTowardsRoot(), null);
+        final QName qname = schemaNode.getPath().getLastComponent();
         Preconditions.checkState(qname != null,
                 "Schema Path contains invalid state of path parts. " +
                         "The Schema Path MUST contain at least ONE QName which defines namespace and Local name of path.");