Skip to content

Commit 358b435

Browse files
author
Daniel Kroening
committed
prefer a ranged for over indexed iteration
1 parent 69a8eaf commit 358b435

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

src/goto-symex/symex_function_call.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ void goto_symext::symex_function_call_code(
282282

283283
// read the arguments -- before the locality renaming
284284
exprt::operandst arguments=call.arguments();
285-
for(unsigned i=0; i<arguments.size(); i++)
286-
state.rename(arguments[i], ns);
285+
for(auto &a : arguments)
286+
state.rename(a, ns);
287287

288288
// produce a new frame
289289
assert(!state.call_stack().empty());

src/java_bytecode/java_types.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ typet java_type_from_string(const std::string &src)
241241
return nil_typet();
242242
std::string class_name=src.substr(1, src.size()-2);
243243

244-
for(unsigned i=0; i<class_name.size(); i++)
245-
if(class_name[i]=='/')
246-
class_name[i]='.';
244+
for(auto &letter : class_name)
245+
if(letter=='/')
246+
letter='.';
247247

248248
std::string identifier="java::"+class_name;
249249
symbol_typet symbol_type(identifier);

src/langapi/language_ui.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ language_uit::~language_uit()
3737

3838
bool language_uit::parse()
3939
{
40-
for(unsigned i=0; i<_cmdline.args.size(); i++)
41-
{
42-
if(parse(_cmdline.args[i]))
40+
for(const auto &filename : _cmdline.args)
41+
if(parse(filename))
4342
return true;
44-
}
4543

4644
return false;
4745
}

src/memory-models/mm2cpp.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ std::string mm2cppt::text2c(const irep_idt &src)
3737
std::string result;
3838
result.reserve(src.size());
3939

40-
for(unsigned i=0; i<src.size(); i++)
40+
for(const auto ch : id2string(src))
4141
{
42-
char ch=src[i];
4342
if(isalnum(ch))
4443
result+=ch;
4544
else

0 commit comments

Comments
 (0)