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 <robert.varga@pantheon.tech>
}
final Optional<R> runtimeTypeOf(final @NonNull S stmt) {
- return recursiveRuntimeType().map(childType -> rebaseRuntimeType(childType, stmt));
- }
-
- public final Optional<R> recursiveRuntimeType() {
- AbstractExplicitGenerator<S, R> 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();