Skip to content

Commit 97cd228

Browse files
author
Daniel Kroening
committed
symex_target_equation: replace loops
improves readability
1 parent b4d27ca commit 97cd228

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

src/goto-symex/symex_target_equation.h

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ Author: Daniel Kroening, [email protected]
1212
#ifndef CPROVER_GOTO_SYMEX_SYMEX_TARGET_EQUATION_H
1313
#define CPROVER_GOTO_SYMEX_SYMEX_TARGET_EQUATION_H
1414

15-
#include <list>
15+
#include <algorithm>
1616
#include <iosfwd>
17+
#include <list>
1718

1819
#include <util/invariant.h>
1920
#include <util/merge_irep.h>
@@ -349,24 +350,18 @@ class symex_target_equationt:public symex_targett
349350

350351
std::size_t count_assertions() const
351352
{
352-
std::size_t i=0;
353-
for(SSA_stepst::const_iterator
354-
it=SSA_steps.begin();
355-
it!=SSA_steps.end(); it++)
356-
if(it->is_assert())
357-
i++;
358-
return i;
353+
return std::count_if(
354+
SSA_steps.begin(), SSA_steps.end(), [](const SSA_stept &step) {
355+
return step.is_assert();
356+
});
359357
}
360358

361359
std::size_t count_ignored_SSA_steps() const
362360
{
363-
std::size_t i=0;
364-
for(SSA_stepst::const_iterator
365-
it=SSA_steps.begin();
366-
it!=SSA_steps.end(); it++)
367-
if(it->ignore)
368-
i++;
369-
return i;
361+
return std::count_if(
362+
SSA_steps.begin(), SSA_steps.end(), [](const SSA_stept &step) {
363+
return step.ignore;
364+
});
370365
}
371366

372367
typedef std::list<SSA_stept> SSA_stepst;
@@ -392,13 +387,10 @@ class symex_target_equationt:public symex_targett
392387

393388
bool has_threads() const
394389
{
395-
for(SSA_stepst::const_iterator it=SSA_steps.begin();
396-
it!=SSA_steps.end();
397-
it++)
398-
if(it->source.thread_nr!=0)
399-
return true;
400-
401-
return false;
390+
return std::any_of(
391+
SSA_steps.begin(), SSA_steps.end(), [](const SSA_stept &step) {
392+
return step.source.thread_nr != 0;
393+
});
402394
}
403395

404396
void validate(const namespacet &ns, const validation_modet vm) const

0 commit comments

Comments
 (0)