Pre-cache child node set 29/10229/2
authorRobert Varga <rovarga@cisco.com>
Sun, 24 Aug 2014 21:48:20 +0000 (23:48 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 26 Aug 2014 15:26:08 +0000 (17:26 +0200)
Tracing has shown this method gets called ~5.7M times, contributing to
some 10% bootup time. Pre-cache the set of nodes to speed things up.

Change-Id: I20bf25b55a4c52a725c160d7d52c6cdd8ce4dfa0
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/util/AbstractDocumentedDataNodeContainer.java

index 30e28d46bde7c04ae1b2e1be768fb34a6f67f2b7..766b61fbce1605e094f920187822eeecc9d186e5 100644 (file)
@@ -26,6 +26,7 @@ public abstract class AbstractDocumentedDataNodeContainer extends AbstractDocume
     private final Set<GroupingDefinition> groupings;
     private final Set<UsesNode> uses;
     private final Set<TypeDefinition<?>> typeDefinitions;
+    private final Set<DataSchemaNode> publicChildNodes;
 
     protected AbstractDocumentedDataNodeContainer(final AbstractDocumentedDataNodeContainerBuilder data) {
         super(data);
@@ -36,6 +37,7 @@ public abstract class AbstractDocumentedDataNodeContainer extends AbstractDocume
         groupings = ImmutableSet.copyOf(data.getGroupings());
         uses = ImmutableSet.copyOf(data.getUsesNodes());
         typeDefinitions = ImmutableSet.copyOf(data.getTypeDefinitions());
+        publicChildNodes = ImmutableSet.copyOf(childNodes.values());
     }
 
     @Override
@@ -45,7 +47,7 @@ public abstract class AbstractDocumentedDataNodeContainer extends AbstractDocume
 
     @Override
     public final Set<DataSchemaNode> getChildNodes() {
-        return ImmutableSet.copyOf(childNodes.values());
+        return publicChildNodes;
     }
 
     @Override