Skip to content

Commit 909bab6

Browse files
Invert the iterator check to reduce cognitive load caused by extended block scope
1 parent 17885de commit 909bab6

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,23 +1030,21 @@ static void find_and_replace_parameter(
10301030
get_final_name_component(
10311031
id2string(replacement_param.type_variable().get_identifier()));
10321032
});
1033+
if(replacement_parameter_it == replacement_parameters.end())
1034+
return;
10331035

1034-
// if a replacement parameter was found, update the identifier
1035-
if(replacement_parameter_it != replacement_parameters.end())
1036-
{
1037-
const std::string &replacement_parameter_full_name =
1038-
id2string(replacement_parameter_it->type_variable().get_identifier());
1039-
1040-
// the replacement parameter is a viable one, i.e., it comes from an outer
1041-
// class
1042-
PRECONDITION(
1043-
get_without_final_name_component(parameter_full_name)
1044-
.compare(get_without_final_name_component(
1045-
replacement_parameter_full_name)) > 0);
1046-
1047-
parameter.type_variable_ref().set_identifier(
1048-
replacement_parameter_full_name);
1049-
}
1036+
// A replacement parameter was found, update the identifier
1037+
const std::string &replacement_parameter_full_name =
1038+
id2string(replacement_parameter_it->type_variable().get_identifier());
1039+
1040+
// the replacement parameter is a viable one, i.e., it comes from an outer
1041+
// class
1042+
PRECONDITION(
1043+
get_without_final_name_component(parameter_full_name)
1044+
.compare(
1045+
get_without_final_name_component(replacement_parameter_full_name)) > 0);
1046+
1047+
parameter.type_variable_ref().set_identifier(replacement_parameter_full_name);
10501048
}
10511049

10521050
/// Recursively find all generic type parameters of a given type and replace

jbmc/src/java_bytecode/select_pointer_type.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,15 @@ pointer_typet select_pointer_typet::specialize_generics(
8989
// if the pointer is an array, recursively specialize its element type
9090
const auto *array_element_type =
9191
type_try_dynamic_cast<pointer_typet>(java_array_element_type(*subtype));
92-
if(array_element_type != nullptr)
93-
{
94-
const pointer_typet &new_array_type = specialize_generics(
95-
*array_element_type,
96-
generic_parameter_specialization_map,
97-
visited_nodes);
98-
99-
pointer_typet replacement_array_type = java_array_type('a');
100-
replacement_array_type.subtype().set(ID_element_type, new_array_type);
101-
return replacement_array_type;
102-
}
92+
if(array_element_type == nullptr)
93+
return pointer_type;
94+
95+
const pointer_typet &new_array_type = specialize_generics(
96+
*array_element_type, generic_parameter_specialization_map, visited_nodes);
97+
98+
pointer_typet replacement_array_type = java_array_type('a');
99+
replacement_array_type.subtype().set(ID_element_type, new_array_type);
100+
return replacement_array_type;
103101
}
104102

105103
return pointer_type;

0 commit comments

Comments
 (0)