From: Danny Al-Gaaf Date: Wed, 13 Feb 2013 13:56:03 +0000 (+0100) Subject: FileStore.cc: use empty() instead of size() to check for emptiness X-Git-Tag: v0.58~66^2~49 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f65679b47ea4cac76425e45a6092710ed16b97e1;p=ceph.git FileStore.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(). Signed-off-by: Danny Al-Gaaf --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 9ce7550d9a5..c91d47c6d0d 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -1495,7 +1495,7 @@ int FileStore::mount() } dout(0) << "mount found snaps " << snaps << dendl; - if (cluster_snaps.size()) + if (!cluster_snaps.empty()) dout(0) << "mount found cluster snaps " << cluster_snaps << dendl; } @@ -3751,7 +3751,7 @@ int FileStore::getattr(coll_t cid, const hobject_t& oid, const char *name, buffe dout(10) << __func__ << " get_xattrs err r =" << r << dendl; goto out; } - if (!got.size()) { + if (got.empty()) { dout(10) << __func__ << " got.size() is 0" << dendl; return -ENODATA; } @@ -4307,7 +4307,7 @@ bool FileStore::collection_empty(coll_t c) assert(!m_filestore_fail_eio || r != -EIO); return false; } - return ls.size() > 0; + return !ls.empty(); } int FileStore::collection_list_range(coll_t c, hobject_t start, hobject_t end, @@ -4328,11 +4328,11 @@ int FileStore::collection_list_range(coll_t c, hobject_t start, hobject_t end, ls->insert(ls->end(), next_objects.begin(), next_objects.end()); // special case for empty collection - if (ls->size() == 0) { + if (ls->empty()) { break; } - while (ls->size() > 0 && ls->back() >= end) { + while (!ls->empty() && ls->back() >= end) { ls->pop_back(); done = true; }