BUG-509: remove StoreMetadataNode.children() 15/7015/1
authorRobert Varga <rovarga@cisco.com>
Thu, 15 May 2014 09:10:36 +0000 (11:10 +0200)
committerRobert Varga <rovarga@cisco.com>
Thu, 15 May 2014 09:10:36 +0000 (11:10 +0200)
This patch removes the now-unneeded access, which means the children
iteration order is no longer part of StoreMetadataNode, allowing us to
use more memory-efficient HashMap instead of LinkedHashMap. Let's do
precisely that.

Change-Id: I0764bfa9861f9df4d3014151db96edf1024e3f9b
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java

index 455777b..b8ad736 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl.tree;
 import static com.google.common.base.Preconditions.checkState;
 
 import java.util.Collections;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.opendaylight.yangtools.concepts.Identifiable;
@@ -21,7 +21,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
 import com.google.common.primitives.UnsignedLong;
 
 public class StoreMetadataNode implements Immutable, Identifiable<PathArgument>, StoreTreeNode<StoreMetadataNode> {
@@ -82,10 +81,6 @@ public class StoreMetadataNode implements Immutable, Identifiable<PathArgument>,
         return this.data;
     }
 
-    public Iterable<StoreMetadataNode> getChildren() {
-        return Iterables.unmodifiableIterable(children.values());
-    }
-
     @Override
     public Optional<StoreMetadataNode> getChild(final PathArgument key) {
         return Optional.fromNullable(children.get(key));
@@ -137,11 +132,11 @@ public class StoreMetadataNode implements Immutable, Identifiable<PathArgument>,
         private boolean dirty = false;
 
         private Builder() {
-            children = new LinkedHashMap<>();
+            children = new HashMap<>();
         }
 
         public Builder(StoreMetadataNode node) {
-            children = new LinkedHashMap<>(node.children);
+            children = new HashMap<>(node.children);
         }
 
         public UnsignedLong getVersion() {
@@ -166,7 +161,7 @@ public class StoreMetadataNode implements Immutable, Identifiable<PathArgument>,
 
         public Builder add(final StoreMetadataNode node) {
             if (dirty) {
-                children = new LinkedHashMap<>(children);
+                children = new HashMap<>(children);
                 dirty = false;
             }
             children.put(node.getIdentifier(), node);
@@ -175,7 +170,7 @@ public class StoreMetadataNode implements Immutable, Identifiable<PathArgument>,
 
         public Builder remove(final PathArgument id) {
             if (dirty) {
-                children = new LinkedHashMap<>(children);
+                children = new HashMap<>(children);
                 dirty = false;
             }
             children.remove(id);