]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/osd/OSD.h: use empty() instead of size()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 7 Feb 2013 19:14:34 +0000 (20:14 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 11 Feb 2013 10:38:02 +0000 (11:38 +0100)
Fix warning for usage of *.size(). Use empty() since it should be
prefered as it has, following the standard, a constant time
complexity regardless of the containter type. The same is not
guaranteed for size().

warning from cppchecker was:
[osd/OSD.h:265]: (performance) Possible inefficient checking for
   'last_scrub_pg' emptiness.
[osd/OSD.h:274]: (performance) Possible inefficient checking for
   'last_scrub_pg' emptiness.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/osd/OSD.h

index b411c177a3665c7cd0d0a3d9664d77ae27663a2a..03d78cc1cd68c9a479d936f2c398670a1418b57b 100644 (file)
@@ -262,7 +262,7 @@ public:
   }
   bool first_scrub_stamp(pair<utime_t, pg_t> *out) {
     Mutex::Locker l(sched_scrub_lock);
-    if (last_scrub_pg.size() == 0)
+    if (last_scrub_pg.empty())
       return false;
     set< pair<utime_t, pg_t> >::iterator iter = last_scrub_pg.begin();
     *out = *iter;
@@ -271,7 +271,7 @@ public:
   bool next_scrub_stamp(pair<utime_t, pg_t> next,
                        pair<utime_t, pg_t> *out) {
     Mutex::Locker l(sched_scrub_lock);
-    if (last_scrub_pg.size() == 0)
+    if (last_scrub_pg.empty())
       return false;
     set< pair<utime_t, pg_t> >::iterator iter = last_scrub_pg.lower_bound(next);
     if (iter == last_scrub_pg.end())