BUG-650: ResolveDataChangeState.inheritedOne should be a Collection 15/10915/1
authorRobert Varga <rovarga@cisco.com>
Mon, 8 Sep 2014 17:20:56 +0000 (19:20 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 8 Sep 2014 17:22:23 +0000 (19:22 +0200)
There is no need to demote this to Iterable just to then use
Iterables.isEmpty(), as we are always initializing it with a collection,
which has a quick isEmpty() method. Also promote its order before
interitedSub, so the slow path can be faster a bit.

Change-Id: Ic536e2420cfae98941ec638510c98ec3a8230c09
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java

index ea95030..828e4e3 100644 (file)
@@ -47,7 +47,7 @@ final class ResolveDataChangeState {
     /**
      * Inherited from immediate parent
      */
-    private final Iterable<Builder> inheritedOne;
+    private final Collection<Builder> inheritedOne;
     private final YangInstanceIdentifier nodeId;
     private final Collection<Node> nodes;
 
@@ -56,7 +56,7 @@ final class ResolveDataChangeState {
     private final Map<DataChangeListenerRegistration<?>, Builder> baseBuilders = new HashMap<>();
 
     private ResolveDataChangeState(final YangInstanceIdentifier nodeId,
-            final Iterable<Builder> inheritedSub, final Iterable<Builder> inheritedOne,
+            final Iterable<Builder> inheritedSub, final Collection<Builder> inheritedOne,
             final Collection<Node> nodes) {
         this.nodeId = Preconditions.checkNotNull(nodeId);
         this.nodes = Preconditions.checkNotNull(nodes);
@@ -138,12 +138,12 @@ final class ResolveDataChangeState {
         if (!nodes.isEmpty()) {
             return true;
         }
-        // Have SUBTREE listeners
-        if (!Iterables.isEmpty(inheritedSub)) {
+        // Have ONE listeners
+        if (!inheritedOne.isEmpty()) {
             return true;
         }
-        // Have ONE listeners
-        if (!Iterables.isEmpty(inheritedOne)) {
+        // Have SUBTREE listeners
+        if (!Iterables.isEmpty(inheritedSub)) {
             return true;
         }