Skip to content

Commit 2aebbff

Browse files
committed
Use ranged-for instead of indexed iteration
1 parent d6bdee6 commit 2aebbff

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/goto-programs/goto_convert.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,15 @@ void goto_convertt::finish_gotos(goto_programt &dest, const irep_idt &mode)
149149
bool stack_is_prefix=true;
150150
if(label_stack.size()>goto_stack.size())
151151
stack_is_prefix=false;
152-
for(std::size_t i=0, ilim=label_stack.size();
153-
i!=ilim && stack_is_prefix;
154-
++i)
152+
auto label_stack_it = label_stack.begin();
153+
for(const auto &g : goto_stack)
155154
{
156-
if(goto_stack[i]!=label_stack[i])
155+
if(!stack_is_prefix || label_stack_it == label_stack.end())
156+
break;
157+
else if(g != *label_stack_it)
157158
stack_is_prefix=false;
159+
160+
++label_stack_it;
158161
}
159162

160163
if(!stack_is_prefix)

0 commit comments

Comments
 (0)