From ca5fbf69c4b2ab1df5ec2632621c8f73eaf126d8 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 14 Jan 2020 15:18:42 +0100 Subject: [PATCH] Optimize DataNodeIterator.hasNext() 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 (cherry picked from commit 1adcabecdcab85b6ed657271758560fc5eeb917f) --- .../yangtools/yang/model/util/DataNodeIterator.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/DataNodeIterator.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/DataNodeIterator.java index d0b0eb309c..e168875b90 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/DataNodeIterator.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/DataNodeIterator.java @@ -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 { @Override public boolean hasNext() { - if (container.getChildNodes() != null) { - final Collection childNodes = container.getChildNodes(); - - if (childNodes != null && !childNodes.isEmpty()) { - return childNodes.iterator().hasNext(); - } - } - return false; + return !container.getChildNodes().isEmpty(); } @Override -- 2.36.6