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

index 25bc48c4550d376c05fba465f46ad8744c1a2cc6..c2357e9454148903d9e0e9b74ca9a3c161868806 100644 (file)
@@ -1863,7 +1863,7 @@ void OSD::calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set<int>& ps
          pset.insert(acting[i]);
        up++;
       }
-    if (!up && acting.size()) {
+    if (!up && !acting.empty()) {
       // sucky.  add down osds, even tho we can't reach them right now.
       for (unsigned i=0; i<acting.size(); i++)
        if (acting[i] != whoami)
@@ -3089,7 +3089,7 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
 
   dout(20) << "do_command tid " << tid << " " << cmd << dendl;
 
-  if (cmd.size() == 0) {
+  if (cmd.empty()) {
     ss << "no command given";
     goto out;
   }
@@ -3169,7 +3169,7 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
        << (end-start) << " sec at " << prettybyte_t(rate) << "/sec";
   }
 
-  else if (cmd.size() >= 1 && cmd[0] == "flush_pg_stats") {
+  else if (!cmd.empty() && cmd[0] == "flush_pg_stats") {
     flush_pg_stats();
   }
   
@@ -4864,7 +4864,7 @@ void OSD::split_pg(PG *parent, map<pg_t,PG*>& children, ObjectStore::Transaction
       object_info_t oi(bv);
 
       t.collection_move(coll_t(pgid), coll_t(parentid), poid);
-      if (oi.snaps.size()) {
+      if (!oi.snaps.empty()) {
        snapid_t first = oi.snaps[0];
        t.collection_move(coll_t(pgid, first), coll_t(parentid), poid);
        if (oi.snaps.size() > 1) {
@@ -5899,7 +5899,7 @@ void OSD::do_recovery(PG *pg)
      */
     if (!started && pg->have_unfound()) {
       pg->discover_all_missing(*rctx.query_map);
-      if (!rctx.query_map->size()) {
+      if (rctx.query_map->empty()) {
        dout(10) << "do_recovery  no luck, giving up on this pg for now" << dendl;
        recovery_wq.lock();
        recovery_wq._dequeue(pg);
@@ -6398,7 +6398,7 @@ void OSD::process_peering_events(
     same_interval_since = MAX(pg->info.history.same_interval_since,
                              same_interval_since);
     pg->write_if_dirty(*rctx.transaction);
-    if (split_pgs.size()) {
+    if (!split_pgs.empty()) {
       rctx.on_applied->add(new C_CompleteSplits(this, split_pgs));
       split_pgs.clear();
     }