Skip to content

Commit c48226f

Browse files
Daniel KroeningPetr Bauch
Daniel Kroening
authored and
Petr Bauch
committed
introduce ranged for
1 parent 75014ac commit c48226f

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

jbmc/src/java_bytecode/java_bytecode_parse_tree.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ void java_bytecode_parse_treet::output(std::ostream &out) const
2323
parsed_class.output(out);
2424

2525
out << "Class references:\n";
26-
for(class_refst::const_iterator it=class_refs.begin();
27-
it!=class_refs.end();
28-
it++)
29-
out << " " << *it << '\n';
26+
for(const auto &class_ref : class_refs)
27+
out << " " << class_ref << '\n';
3028
}
3129

3230
void java_bytecode_parse_treet::classt::output(std::ostream &out) const
@@ -42,23 +40,13 @@ void java_bytecode_parse_treet::classt::output(std::ostream &out) const
4240
out << " extends " << super_class;
4341
out << " {" << '\n';
4442

45-
for(fieldst::const_iterator
46-
it=fields.begin();
47-
it!=fields.end();
48-
it++)
49-
{
50-
it->output(out);
51-
}
43+
for(const auto &field : fields)
44+
field.output(out);
5245

5346
out << '\n';
5447

55-
for(methodst::const_iterator
56-
it=methods.begin();
57-
it!=methods.end();
58-
it++)
59-
{
60-
it->output(out);
61-
}
48+
for(const auto &method : methods)
49+
method.output(out);
6250

6351
out << '}' << '\n';
6452
out << '\n';
@@ -175,16 +163,18 @@ void java_bytecode_parse_treet::methodt::output(std::ostream &out) const
175163
out << " " << i.address << ": ";
176164
out << i.statement;
177165

178-
for(std::vector<exprt>::const_iterator
179-
a_it=i.args.begin(); a_it!=i.args.end(); a_it++)
166+
bool first = true;
167+
for(const auto &arg : i.args)
180168
{
181-
if(a_it!=i.args.begin())
169+
if(first)
170+
first = false;
171+
else
182172
out << ',';
183-
#if 0
184-
out << ' ' << from_expr(*a_it);
185-
#else
186-
out << ' ' << expr2java(*a_it, ns);
187-
#endif
173+
#if 0
174+
out << ' ' << from_expr(arg);
175+
#else
176+
out << ' ' << expr2java(arg, ns);
177+
#endif
188178
}
189179

190180
out << '\n';

0 commit comments

Comments
 (0)