Skip to content

Commit 0c0d997

Browse files
Use zip to get rid of index in loop
Using zip in a range-for loop makes it clearer that we iterate over both components and rhs operands, rather than having to look at how index `i` is used to tie the two together.
1 parent 47ec269 commit 0c0d997

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/goto-symex/symex_assign.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,21 +399,20 @@ void goto_symext::symex_assign_from_struct(
399399
const struct_union_typet::componentst &components = type.components();
400400
PRECONDITION(rhs.operands().size() == components.size());
401401

402-
for(std::size_t i = 0; i < components.size(); ++i)
402+
for(const auto &comp_rhs : make_range(components).zip(rhs.operands()))
403403
{
404-
const auto &comp = components[i];
404+
const auto &comp = comp_rhs.first;
405405
const exprt lhs_field = state.field_sensitivity.apply(
406406
ns, state, member_exprt{lhs, comp.get_name(), comp.type()}, true);
407407
INVARIANT(
408408
lhs_field.id() == ID_symbol,
409409
"member of symbol should be susceptible to field-sensitivity");
410410

411-
const exprt &rhs_field = rhs.operands()[i];
412411
symex_assign_symbol(
413412
state,
414413
to_ssa_expr(lhs_field),
415414
full_lhs,
416-
rhs_field,
415+
comp_rhs.second,
417416
guard,
418417
assignment_type);
419418
}

0 commit comments

Comments
 (0)