From f7f0d6c7560a8f71707e7852a512469147aa9f84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 20:53:28 +0200 Subject: cppcheck complains about some possible speed improvements which could be done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types. --- test/libapt/assert.h | 8 ++++++++ test/libapt/getarchitectures_test.cc | 7 ------- test/libapt/getlanguages_test.cc | 7 ------- test/libapt/getlistoffilesindir_test.cc | 7 ------- test/test_udevcdrom.cc | 2 +- 5 files changed, 9 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/test/libapt/assert.h b/test/libapt/assert.h index 92b662dfa..fae9b6c64 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -53,3 +53,11 @@ void assertEqualsOr2(int const &expect1, int const &expect2, unsigned int const assertEqualsOr2(expect1, expect2, get, line); } + +// simple helper to quickly output a vectors +template < typename X > +void dumpVector(X vec) { + for (typename X::const_iterator v = vec.begin(); + v != vec.end(); ++v) + std::cout << *v << std::endl; +} diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc index e3ca7bbc2..807469263 100644 --- a/test/libapt/getarchitectures_test.cc +++ b/test/libapt/getarchitectures_test.cc @@ -7,13 +7,6 @@ #include -// simple helper to quickly output a vector of strings -void dumpVector(std::vector vec) { - for (std::vector::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - int main(int argc,char *argv[]) { std::vector vec; diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index 3d63e0e74..f6aa7a697 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -7,13 +7,6 @@ #include -// simple helper to quickly output a vector of strings -void dumpVector(std::vector vec) { - for (std::vector::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - int main(int argc,char *argv[]) { if (argc != 2) { diff --git a/test/libapt/getlistoffilesindir_test.cc b/test/libapt/getlistoffilesindir_test.cc index ed8d2dad6..5ee014cca 100644 --- a/test/libapt/getlistoffilesindir_test.cc +++ b/test/libapt/getlistoffilesindir_test.cc @@ -7,13 +7,6 @@ #include #include -// simple helper to quickly output a vector of strings -void dumpVector(std::vector vec) { - for (std::vector::const_iterator v = vec.begin(); - v != vec.end(); v++) - std::cout << *v << std::endl; -} - #define P(x) string(argv[1]).append("/").append(x) int main(int argc,char *argv[]) diff --git a/test/test_udevcdrom.cc b/test/test_udevcdrom.cc index e65c7a297..577e2d013 100644 --- a/test/test_udevcdrom.cc +++ b/test/test_udevcdrom.cc @@ -10,7 +10,7 @@ int main() vector l; l = c.Scan(); - assert(l.size() > 0); + assert(l.empty() == false); for (i=0;i