Do not use Iterables when we have a collection 64/16964/2
authorRobert Varga <rovarga@cisco.com>
Sun, 22 Mar 2015 21:16:36 +0000 (22:16 +0100)
committerRobert Varga <rovarga@cisco.com>
Sun, 22 Mar 2015 21:28:32 +0000 (22:28 +0100)
Ever since Ifa6260ebe157c9afde49bbb58043d6ec2fecd189 normalized node
containers and lists expose children as a collection, not iterable. That
means we have direct access to Collection#size(), so let's use that
instead of redirecting through Iterables.

Change-Id: I01c245b6b9daa9512e246213dd346f66c77a5a94
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NormalizedNodeContainerModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnkeyedListModificationStrategy.java

index 5b924d78d5075d6a38013846ee078067ec8f4c8f..053d0b02274b5108e7820cfe70c9562e353485e7 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 import static com.google.common.base.Preconditions.checkArgument;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
+import java.util.Collection;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
@@ -79,7 +79,7 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp
         final NormalizedNode<?, ?> newValue = modification.getWrittenValue();
         final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version);
 
-        if (Iterables.isEmpty(modification.getChildren())) {
+        if (modification.getChildren().isEmpty()) {
             return newValueMeta;
         }
 
@@ -158,8 +158,8 @@ abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareAp
          * The user has issued an empty merge operation. In this case we do not perform
          * a data tree mutation, do not pass GO, and do not collect useless garbage.
          */
-        final Iterable<ModifiedNode> children = modification.getChildren();
-        if (Iterables.isEmpty(children)) {
+        final Collection<ModifiedNode> children = modification.getChildren();
+        if (children.isEmpty()) {
             newMeta.setData(currentMeta.getData());
             return newMeta.seal();
         }
index ace568fd21924a3fc16d3f604d5dbc8d4f9373be..23140b86a68cb86b597dabf44ce985fdb78b2e58 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import com.google.common.base.Optional;
-import com.google.common.collect.Iterables;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -54,7 +53,7 @@ final class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation {
         final NormalizedNode<?, ?> newValue = modification.getWrittenValue();
         final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version);
 
-        if (Iterables.isEmpty(modification.getChildren())) {
+        if (modification.getChildren().isEmpty()) {
             return newValueMeta;
         }
 
@@ -130,4 +129,4 @@ final class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation {
             final Optional<TreeNode> current) throws IncorrectDataStructureException {
         throw new IncorrectDataStructureException(path, "Subtree modification is not allowed.");
     }
-}
\ No newline at end of file
+}