Use Iterables.filter() instead of FluentIterable 09/75909/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 10 Sep 2018 08:36:12 +0000 (10:36 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 10 Sep 2018 08:39:00 +0000 (10:39 +0200)
This removes allocation of one instance of FluentIterable, reducing
the amount of garbage we produce.

Change-Id: I93953f1263426f7fff20e579e56f82506fb423d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/DataSchemaContextNode.java

index a83373457e9bca4df43f653b9418076c03a9b0c3..7f2117fcc5b41d87433455a1d19670a5d2ee771d 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.util;
 
-import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
@@ -108,17 +108,13 @@ public abstract class DataSchemaContextNode<T extends PathArgument> implements I
     }
 
     static DataSchemaNode findChildSchemaNode(final DataNodeContainer parent, final QName child) {
-        DataSchemaNode potential = parent.getDataChildByName(child);
-        if (potential == null) {
-            Iterable<ChoiceSchemaNode> choices = FluentIterable.from(
-                    parent.getChildNodes()).filter(ChoiceSchemaNode.class);
-            potential = findChoice(choices, child);
-        }
-        return potential;
+        final DataSchemaNode potential = parent.getDataChildByName(child);
+        return potential == null ? findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child)
+                : potential;
     }
 
     static DataSchemaContextNode<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) {
-        DataSchemaNode result = findChildSchemaNode(schema, child);
+        final DataSchemaNode result = findChildSchemaNode(schema, child);
         // We try to look up if this node was added by augmentation
         if (result != null && schema instanceof DataSchemaNode && result.isAugmenting()) {
             return fromAugmentation(schema, (AugmentationTarget) schema, result);