From 2037a8c6e17b521c9ccf1ee3a1a965fa96cade3d Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 14 Mar 2022 00:05:02 +0100 Subject: [PATCH] Remove AbstractExplicitGenerator.recursiveRuntimeType() A potential identified in the bug report is repetitive creation of the same runtime type, when it clearly should be reused. Make sure we recognize when we are dealing with the same statement and eliminate one Optional.map() indirection. JIRA: MDSAL-735 Change-Id: Iaa97a04f58465b302666ca082a887fde9616282a Signed-off-by: Robert Varga --- .../generator/impl/reactor/AbstractExplicitGenerator.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/reactor/AbstractExplicitGenerator.java b/binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/reactor/AbstractExplicitGenerator.java index 3ca83a023d..67883f3f94 100644 --- a/binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/reactor/AbstractExplicitGenerator.java +++ b/binding/mdsal-binding-generator/src/main/java/org/opendaylight/mdsal/binding/generator/impl/reactor/AbstractExplicitGenerator.java @@ -92,15 +92,11 @@ public abstract class AbstractExplicitGenerator runtimeTypeOf(final @NonNull S stmt) { - return recursiveRuntimeType().map(childType -> rebaseRuntimeType(childType, stmt)); - } - - public final Optional recursiveRuntimeType() { - AbstractExplicitGenerator gen = this; + var gen = this; do { final var ret = gen.runtimeType(); if (ret.isPresent()) { - return ret; + return Optional.of(rebaseRuntimeType(ret.orElseThrow(), stmt)); } gen = gen.previous(); -- 2.36.6