From 5d899969c225dbc7814dbf4e704b98c563765afe Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Wed, 13 Feb 2013 15:03:31 +0100 Subject: [PATCH] OSD.cc: use empty() instead of size() to check for emptiness 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 --- src/osd/OSD.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 25bc48c4550d3..c2357e9454148 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1863,7 +1863,7 @@ void OSD::calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set& 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& 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& 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& 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(); } -- 2.39.5