Skip to content

Commit c31d43f

Browse files
author
Owen Jones
committed
Remove code duplication
1 parent 945f885 commit c31d43f

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/java_bytecode/ci_lazy_methods.cpp

+8-18
Original file line numberDiff line numberDiff line change
@@ -425,26 +425,16 @@ void ci_lazy_methodst::get_virtual_method_targets(
425425
!call_basename.empty(),
426426
"Virtual function must have a reasonable name after removing class");
427427

428-
const irep_idt &self_method=
429-
get_virtual_method_target(
430-
instantiated_classes, call_basename, call_class, symbol_table);
428+
class_hierarchyt::idst self_and_child_classes =
429+
class_hierarchy.get_children_trans(call_class);
430+
self_and_child_classes.push_back(call_class);
431431

432-
if(!self_method.empty())
432+
for(const irep_idt &class_name : self_and_child_classes)
433433
{
434-
callable_methods.push_back(self_method);
435-
}
436-
437-
const auto child_classes=class_hierarchy.get_children_trans(call_class);
438-
for(const auto &child_class : child_classes)
439-
{
440-
const auto child_method=
441-
get_virtual_method_target(
442-
instantiated_classes,
443-
call_basename,
444-
child_class,
445-
symbol_table);
446-
if(!child_method.empty())
447-
callable_methods.push_back(child_method);
434+
const irep_idt method_name = get_virtual_method_target(
435+
instantiated_classes, call_basename, class_name, symbol_table);
436+
if(!method_name.empty())
437+
callable_methods.push_back(method_name);
448438
}
449439
}
450440

0 commit comments

Comments
 (0)