From: Robert Varga Date: Thu, 15 May 2014 09:10:36 +0000 (+0200) Subject: BUG-509: remove StoreMetadataNode.children() X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~85^2~1 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=67db8d6568048d1e5b56b626b11b1aa57211e79c BUG-509: remove StoreMetadataNode.children() 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 --- diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java index 455777b7fb..b8ad7368b5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreMetadataNode.java @@ -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, StoreTreeNode { @@ -82,10 +81,6 @@ public class StoreMetadataNode implements Immutable, Identifiable, return this.data; } - public Iterable getChildren() { - return Iterables.unmodifiableIterable(children.values()); - } - @Override public Optional getChild(final PathArgument key) { return Optional.fromNullable(children.get(key)); @@ -137,11 +132,11 @@ public class StoreMetadataNode implements Immutable, Identifiable, 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, 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, public Builder remove(final PathArgument id) { if (dirty) { - children = new LinkedHashMap<>(children); + children = new HashMap<>(children); dirty = false; } children.remove(id);