* src/sanity/style.test: Warn about places where size() is used

instead of empty().
* src/misc/bddalloc.cc (bdd_allocator::extend): Use empty() rather
than size() when checking emptiness of lists.
* src/tgbaalgos/reductgba_sim_del.cc, src/tgbaalgos/minimalce.cc,
src/ltlvisit/basicreduce.cc, src/ltlvisit/reduce.cc,
src/tgbaalgos/gtec/ce.cc, src/tgbaalgos/ltl2tgba_fm.cc,
src/misc/minato.cc: Likewise.
* src/ltlast/multop.cc (multop::instance): Call ->size() only once.
This commit is contained in:
Alexandre Duret-Lutz 2004-09-21 13:01:27 +00:00
parent f0aa58034c
commit c30823f7be
11 changed files with 57 additions and 39 deletions

View file

@ -108,18 +108,23 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do
grep '{.*{' $tmp &&
diag 'No two { on the same line.'
grep -e 'delete[ ]*[(][^(]*[)];' $tmp &&
grep 'delete[ ]*[(][^(]*[)];' $tmp &&
diag 'No useless parentheses after delete.'
grep -e 'return[ ]*[(][^(]*[)];' $tmp &&
grep 'return[ ]*[(][^(]*[)];' $tmp &&
diag 'No useless parentheses after return.'
grep 'NULL' $tmp &&
diag 'Use 0 instead of NULL. NULL is not portable.'
# std::list::size() can be O(n). Better use empty() whenever
# possible, even for other containers.
grep -E '(->|[.])size\(\) [=!]= 0|![a-zA-Z0-9_]*(->|[.])size\(\)|(if |while |assert)\([a-zA-Z0-9_]*(->|[.])size\(\)\)' $tmp &&
diag 'Prefer empty() to check emptiness.'
case $file in
*.hh | *.hxx)
if grep -e '(cout|cerr|clog)' $tmp >/dev/null; then
if grep -E '(cout|cerr|clog)' $tmp >/dev/null; then
:
else
grep '#.*include.*<iostream>' $tmp &&