From: Danny Al-Gaaf Date: Tue, 12 Feb 2013 17:44:04 +0000 (+0100) Subject: client/Client.cc: use empty() instead of size() X-Git-Tag: v0.58~54^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5c3e6570a35b00d18244a12274eb3edad5e332bd;p=ceph.git client/Client.cc: use empty() instead of size() 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(). warning from cppchecker was: [src/client/Client.cc:3649]: (performance) Possible inefficient checking for 'mds_sessions' emptiness. [src/client/Client.cc:7489]: (performance) Possible inefficient checking for 'osds' emptiness. Signed-off-by: Danny Al-Gaaf --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 5350802b0f48..2afb88bf1fb0 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3646,7 +3646,7 @@ void Client::unmount() } // wait for sessions to close - while (mds_sessions.size()) { + while (!mds_sessions.empty()) { ldout(cct, 2) << "waiting for " << mds_sessions.size() << " mds sessions to close" << dendl; mount_cond.Wait(client_lock); } @@ -7486,7 +7486,7 @@ int Client::get_file_stripe_address(int fd, loff_t offset, vector pg_t pg = osdmap->object_locator_to_pg(extents[0].oid, extents[0].oloc); vector osds; osdmap->pg_to_acting_osds(pg, osds); - if (!osds.size()) + if (osds.empty()) return -EINVAL; for (unsigned i = 0; i < osds.size(); i++) {