]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
PG.cc: use empty() instead of size() to check for emptiness
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 14:18:55 +0000 (15:18 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 14:18:55 +0000 (15:18 +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().

This replaces also some size() >=/== checks.

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

index 7fd4144983dd2419635d99aff9b3873125f42326..b66d9924bca798883c094cfac89516182b67811a 100644 (file)
@@ -2816,7 +2816,7 @@ void PG::update_snap_collections(vector<pg_log_entry_t> &log_entries,
       } catch (...) {
        snaps.clear();
       }
-      if (snaps.size()) {
+      if (!snaps.empty()) {
        make_snap_collection(t, snaps[0]);
        if (snaps.size() > 1)
          make_snap_collection(t, *(snaps.rbegin()));
@@ -3803,7 +3803,7 @@ void PG::chunky_scrub() {
             start = scrubber.end;
 
             // special case: reached end of file store, implicitly a boundary
-            if (objects.size() == 0) {
+            if (objects.empty()) {
               break;
             }
 
@@ -4121,13 +4121,13 @@ void PG::_compare_scrubmaps(const map<int,ScrubMap*> &maps,
       }
     }
     assert(auth != maps.end());
-    if (cur_missing.size()) {
+    if (!cur_missing.empty()) {
       missing[*k] = cur_missing;
     }
-    if (cur_inconsistent.size()) {
+    if (!cur_inconsistent.empty()) {
       inconsistent[*k] = cur_inconsistent;
     }
-    if (cur_inconsistent.size() || cur_missing.size()) {
+    if (!cur_inconsistent.empty() || !cur_missing.empty()) {
       authoritative[*k] = auth->first;
     }
   }
@@ -4162,7 +4162,7 @@ void PG::scrub_compare_maps() {
       ss);
     dout(2) << ss.str() << dendl;
 
-    if (authoritative.size() || scrubber.inconsistent_snapcolls.size()) {
+    if (!authoritative.empty() || !scrubber.inconsistent_snapcolls.empty()) {
       osd->clog.error(ss);
     }
 
@@ -4186,7 +4186,7 @@ void PG::scrub_process_inconsistent() {
   bool deep_scrub = state_test(PG_STATE_DEEP_SCRUB);
   const char *mode = (repair ? "repair": (deep_scrub ? "deep-scrub" : "scrub"));
 
-  if (scrubber.authoritative.size() || scrubber.inconsistent.size()) {
+  if (!scrubber.authoritative.empty() || !scrubber.inconsistent.empty()) {
     stringstream ss;
     for (map<hobject_t, set<int> >::iterator obj =
           scrubber.inconsistent_snapcolls.begin();
@@ -4735,7 +4735,7 @@ void PG::start_peering_interval(const OSDMapRef lastmap,
   osd->remove_want_pg_temp(info.pgid);
   cancel_recovery();
 
-  if (acting.empty() && up.size() && up[0] == osd->whoami) {
+  if (acting.empty() && !up.empty() && up[0] == osd->whoami) {
     dout(10) << " acting empty, but i am up[0], clearing pg_temp" << dendl;
     osd->queue_want_pg_temp(info.pgid, acting);
   }
@@ -4776,7 +4776,7 @@ ostream& operator<<(ostream& out, const PG& pg)
   out << " r=" << pg.get_role();
   out << " lpr=" << pg.get_last_peering_reset();
 
-  if (pg.past_intervals.size()) {
+  if (!pg.past_intervals.empty()) {
     out << " pi=" << pg.past_intervals.begin()->first << "-" << pg.past_intervals.rbegin()->second.last
        << "/" << pg.past_intervals.size();
   }
@@ -6701,7 +6701,7 @@ PG::RecoveryState::GetLog::GetLog(my_context ctx) :
 
   // adjust acting?
   if (!pg->choose_acting(newest_update_osd)) {
-    if (pg->want_acting.size()) {
+    if (!pg->want_acting.empty()) {
       post_event(NeedActingChange());
     } else {
       post_event(IsIncomplete());