]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client/Client.cc: use empty() instead of size()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 12 Feb 2013 17:44:04 +0000 (18:44 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 15 Feb 2013 20:55:08 +0000 (21:55 +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().

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 <danny.al-gaaf@bisect.de>
src/client/Client.cc

index 5350802b0f486bfa92f762db2d69843c46fc0741..2afb88bf1fb02ce63f66d5182e74ece7ce78239a 100644 (file)
@@ -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<entity_addr_t>
   pg_t pg = osdmap->object_locator_to_pg(extents[0].oid, extents[0].oloc);
   vector<int> osds;
   osdmap->pg_to_acting_osds(pg, osds);
-  if (!osds.size())
+  if (osds.empty())
     return -EINVAL;
 
   for (unsigned i = 0; i < osds.size(); i++) {