From b386aa9fe9e1e63c1698cb3c159aa21c1b943b53 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 25 Oct 2020 21:05:39 +0100 Subject: [PATCH] Speed up NormalizedNodes.getDirectChild() Deal with positive matches first, let ValueNode be dealt with using the default path. Change-Id: If74b9ee05f0a4b5fb867e4b2db5f53bb06728e38 Signed-off-by: Robert Varga --- .../yangtools/yang/data/api/schema/NormalizedNodes.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodes.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodes.java index 0ff92be608..5706bd3278 100644 --- a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodes.java +++ b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodes.java @@ -108,15 +108,14 @@ public final class NormalizedNodes { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Optional> getDirectChild(final NormalizedNode node, final PathArgument pathArg) { - if (node instanceof ValueNode) { - return Optional.empty(); - } else if (node instanceof DataContainerNode) { + if (node instanceof DataContainerNode) { return (Optional) ((DataContainerNode) node).getChild(pathArg); } else if (node instanceof MapNode && pathArg instanceof NodeIdentifierWithPredicates) { return (Optional) ((MapNode) node).getChild((NodeIdentifierWithPredicates) pathArg); } else if (node instanceof LeafSetNode && pathArg instanceof NodeWithValue) { return (Optional) ((LeafSetNode) node).getChild((NodeWithValue) pathArg); } + // Anything else, including ValueNode return Optional.empty(); } -- 2.36.6