]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMonitor.h: use !reporters.empty() instead of size()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 13:10:21 +0000 (14:10 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 13:10:21 +0000 (14:10 +0100)
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().

Using empty() in this case makes the code more logical.

warning from cppcheck was:

[src/mon/OSDMonitor.h:59]: (performance) Possible inefficient
  checking for 'reporters' emptiness.

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

index f35992c43121d346ba54e7ee9e470b4bc105794c..05c484ed652682ae64c155239affc597f2861214 100644 (file)
@@ -56,7 +56,7 @@ struct failure_info_t {
   failure_info_t() : num_reports(0) {}
 
   utime_t get_failed_since() {
-    if (max_failed_since == utime_t() && reporters.size()) {
+    if (max_failed_since == utime_t() && !reporters.empty()) {
       // the old max must have canceled; recalculate.
       for (map<int, failure_reporter_t>::iterator p = reporters.begin();
           p != reporters.end();