Skip to content

Commit b7b2eb1

Browse files
committed
Make struct_union_typet::component_type return a const reference
There is no need for a copy.
1 parent 49a3af2 commit b7b2eb1

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ java_string_library_preprocesst::process_equals_function_operands(
392392
/// \param type: a type containing a "data" component
393393
/// \param symbol_table: symbol table
394394
/// \return type of the "data" component
395-
static typet get_data_type(const typet &type, const symbol_tablet &symbol_table)
395+
static const typet&
396+
get_data_type(const typet &type, const symbol_tablet &symbol_table)
396397
{
397398
PRECONDITION(type.id() == ID_struct || type.id() == ID_symbol_type);
398399
if(type.id() == ID_symbol_type)
@@ -410,7 +411,7 @@ static typet get_data_type(const typet &type, const symbol_tablet &symbol_table)
410411
/// \param type: a type containing a "length" component
411412
/// \param symbol_table: symbol table
412413
/// \return type of the "length" component
413-
static typet
414+
static const typet&
414415
get_length_type(const typet &type, const symbol_tablet &symbol_table)
415416
{
416417
PRECONDITION(type.id() == ID_struct || type.id() == ID_symbol_type);

src/pointer-analysis/value_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ exprt value_sett::make_member(
17561756
}
17571757

17581758
// give up
1759-
typet subtype=struct_union_type.component_type(component_name);
1759+
const typet &subtype = struct_union_type.component_type(component_name);
17601760
member_exprt member_expr(src, component_name, subtype);
17611761

17621762
return member_expr;

src/util/std_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ const struct_union_typet::componentt &struct_union_typet::get_component(
7272
return static_cast<const componentt &>(get_nil_irep());
7373
}
7474

75-
typet struct_union_typet::component_type(
75+
const typet &struct_union_typet::component_type(
7676
const irep_idt &component_name) const
7777
{
78-
const exprt c=get_component(component_name);
78+
const auto &c = get_component(component_name);
7979
assert(c.is_not_nil());
8080
return c.type();
8181
}

src/util/std_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class struct_union_typet:public typet
212212
const irep_idt &component_name) const;
213213

214214
std::size_t component_number(const irep_idt &component_name) const;
215-
typet component_type(const irep_idt &component_name) const;
215+
const typet &component_type(const irep_idt &component_name) const;
216216

217217
irep_idt get_tag() const { return get(ID_tag); }
218218
void set_tag(const irep_idt &tag) { set(ID_tag, tag); }

0 commit comments

Comments
 (0)