Skip to content

Commit 52d0fe4

Browse files
Make build_offset_map return an offset_mapt
1 parent 2dc7bee commit 52d0fe4

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/solvers/flattening/boolbv.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -660,17 +660,16 @@ void boolbvt::print_assignment(std::ostream &out) const
660660
out << pair.first << "=" << pair.second.get_value(prop) << '\n';
661661
}
662662

663-
void boolbvt::build_offset_map(const struct_typet &src, offset_mapt &dest)
663+
boolbvt::offset_mapt boolbvt::build_offset_map(const struct_typet &src)
664664
{
665-
const struct_typet::componentst &components=
666-
src.components();
667-
668-
dest.resize(components.size());
669-
std::size_t offset=0;
670-
for(std::size_t i=0; i<components.size(); i++)
665+
const struct_typet::componentst &components = src.components();
666+
offset_mapt dest;
667+
dest.reserve(components.size());
668+
std::size_t offset = 0;
669+
for(const auto &comp : components)
671670
{
672-
std::size_t comp_width=boolbv_width(components[i].type());
673-
dest[i]=offset;
674-
offset+=comp_width;
671+
dest.push_back(offset);
672+
offset += boolbv_width(comp.type());
675673
}
674+
return dest;
676675
}

src/solvers/flattening/boolbv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class boolbvt:public arrayst
250250
void post_process_quantifiers();
251251

252252
typedef std::vector<std::size_t> offset_mapt;
253-
void build_offset_map(const struct_typet &src, offset_mapt &dest);
253+
offset_mapt build_offset_map(const struct_typet &src);
254254

255255
// strings
256256
numbering<irep_idt> string_numbering;

src/solvers/flattening/boolbv_typecast.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,8 @@ bool boolbvt::type_conversion(
530530
op_struct.components();
531531

532532
// build offset maps
533-
offset_mapt op_offsets, dest_offsets;
534-
535-
build_offset_map(op_struct, op_offsets);
536-
build_offset_map(dest_struct, dest_offsets);
533+
const offset_mapt op_offsets = build_offset_map(op_struct);
534+
const offset_mapt dest_offsets = build_offset_map(dest_struct);
537535

538536
// build name map
539537
typedef std::map<irep_idt, std::size_t> op_mapt;

0 commit comments

Comments
 (0)