Optimize DataNodeIterator.hasNext() 91/86891/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 14 Jan 2020 14:18:42 +0000 (15:18 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 14 Jan 2020 17:22:08 +0000 (17:22 +0000)
This does not quite make sense, but can be optimized to only quickly
look at the collection.

Change-Id: Iabc8414ff712126699f54c02f5aaf9506c4f3f6b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1adcabecdcab85b6ed657271758560fc5eeb917f)

yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/DataNodeIterator.java

index d0b0eb309ccc05afee7914d1d3c65d8985a5302e..e168875b90b38d9c1f2880271be4369332b9be7f 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -170,14 +169,7 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
 
     @Override
     public boolean hasNext() {
-        if (container.getChildNodes() != null) {
-            final Collection<DataSchemaNode> childNodes = container.getChildNodes();
-
-            if (childNodes != null && !childNodes.isEmpty()) {
-                return childNodes.iterator().hasNext();
-            }
-        }
-        return false;
+        return !container.getChildNodes().isEmpty();
     }
 
     @Override