From: Xinze Chi Date: Tue, 27 Jan 2015 07:17:44 +0000 (+0000) Subject: cleanup: replace some size() with !empty() X-Git-Tag: v0.93~162^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=17add067275aa86d29a07b0e136f591fa55647bd;p=ceph.git cleanup: replace some size() with !empty() Signed-off-by: Xinze Chi --- diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index 6c28a89dce33..42d1eafe7005 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -181,9 +181,9 @@ public: } // This function maybe needs some work; assumes last event is completion time double get_duration() const { - return events.size() ? - (events.rbegin()->first - get_initiated()) : - 0.0; + return events.empty() ? + 0.0 : + (events.rbegin()->first - get_initiated()); } void mark_event(const string &event); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 8cf6e3c714a0..e31da938a0e5 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -6809,7 +6809,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr) } if (reply_witness) { - assert(srcdnrep.size()); + assert(!srcdnrep.empty()); MMDSSlaveRequest *reply = new MMDSSlaveRequest(mdr->reqid, mdr->attempt, MMDSSlaveRequest::OP_RENAMEPREPACK); reply->witnesses.swap(srcdnrep); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 6029bf0a3dfd..4b04362757d6 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6466,7 +6466,7 @@ done: } string out_str; err = reweight_by_utilization(oload, out_str, true, - pools.size() ? &pools : NULL); + pools.empty() ? NULL : &pools); if (err < 0) { ss << "FAILED reweight-by-pg: " << out_str; } else if (err == 0) { diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index d15267291f80..fe7bc17ee9da 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -563,9 +563,9 @@ void ReplicatedBackend::submit_transaction( reqid, trim_to, trim_rollback_to, - t->get_temp_added().size() ? *(t->get_temp_added().begin()) : hobject_t(), - t->get_temp_cleared().size() ? - *(t->get_temp_cleared().begin()) :hobject_t(), + t->get_temp_added().empty() ? hobject_t() : *(t->get_temp_added().begin()), + t->get_temp_cleared().empty() ? + hobject_t() : *(t->get_temp_cleared().begin()), log_entries, hset_history, &op, @@ -573,7 +573,7 @@ void ReplicatedBackend::submit_transaction( ObjectStore::Transaction local_t; local_t.set_use_tbl(op_t->get_use_tbl()); - if (t->get_temp_added().size()) { + if (!(t->get_temp_added().empty())) { get_temp_coll(&local_t); add_temp_objs(t->get_temp_added()); } diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 5ebf34dc29d5..56792a4275d8 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -11263,8 +11263,8 @@ int ReplicatedPG::recover_backfill( dout(20) << *i << " is still in flight" << dendl; } - hobject_t next_backfill_to_complete = backfills_in_flight.size() ? - *(backfills_in_flight.begin()) : backfill_pos; + hobject_t next_backfill_to_complete = backfills_in_flight.empty() ? + backfill_pos : *(backfills_in_flight.begin()); hobject_t new_last_backfill = earliest_backfill(); dout(10) << "starting new_last_backfill at " << new_last_backfill << dendl; for (map::iterator i = pending_backfill_updates.begin();