Skip to content

Commit 4a5a29a

Browse files
author
Owen Jones
committed
Remove code duplication
1 parent e262384 commit 4a5a29a

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/java_bytecode/ci_lazy_methods.cpp

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

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

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

0 commit comments

Comments
 (0)