Skip to content

Commit 829d5e9

Browse files
committed
Clean up uses of is_primitive_wrapper_type_name that derive the name from a symbol-table id
These users start with an irep_idt, so it's cheaper to look up by id than to create a derived string and then look up by that.
1 parent 579a2ce commit 829d5e9

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

jbmc/src/java_bytecode/assignments_from_json.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,7 @@ static code_with_references_listt assign_struct_components_from_json(
543543
else // component is class field (pointer to struct)
544544
{
545545
const auto member_json = [&]() -> jsont {
546-
if(
547-
is_primitive_wrapper_type_name(id2string(
548-
strip_java_namespace_prefix(java_class_type.get_name()))) &&
546+
if(is_primitive_wrapper_type_id(java_class_type.get_name()) &&
549547
id2string(component_name) == "value")
550548
{
551549
return get_untyped_primitive(json);

jbmc/src/java_bytecode/java_utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ get_java_primitive_type_info(const typet &maybe_primitive_type)
104104
return found == type_info_by_primitive_type.end() ? nullptr : &found->second;
105105
}
106106

107+
bool is_primitive_wrapper_type_id(const irep_idt &id) {
108+
return get_boxed_type_info_by_name(id) != nullptr;
109+
}
110+
107111
bool is_primitive_wrapper_type_name(const std::string &type_name)
108112
{
109113
static const std::unordered_set<std::string> primitive_wrapper_type_names = {

jbmc/src/java_bytecode/java_utils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ struct java_boxed_type_infot
6262
const java_boxed_type_infot *
6363
get_boxed_type_info_by_name(const irep_idt &type_name);
6464

65+
/// Returns true iff the argument is the symbol-table identifier of a Java
66+
/// primitive wrapper type (for example, java::java.lang.Byte)
67+
bool is_primitive_wrapper_type_id(const irep_idt &id);
68+
6569
/// Returns true iff the argument is the fully qualified name of a Java
66-
/// primitive wrapper type.
70+
/// primitive wrapper type (for example, java.lang.Byte)
6771
bool is_primitive_wrapper_type_name(const std::string &type_name);
6872

6973
void generate_class_stub(

0 commit comments

Comments
 (0)