From: Robert Varga Date: Sun, 13 Mar 2022 23:05:02 +0000 (+0100) Subject: Remove AbstractExplicitGenerator.recursiveRuntimeType() X-Git-Tag: v9.0.0~6 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=commitdiff_plain;h=2037a8c6e17b521c9ccf1ee3a1a965fa96cade3d 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 --- 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();