]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
DBObjectMap.cc: use empty() instead of size() to check for emptiness
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 13:51:28 +0000 (14:51 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 13:51:28 +0000 (14:51 +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().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/os/DBObjectMap.cc

index f884266ff7512121b9195d18728d1d2e76cdf760..c3a4c3b9869a299976f1c4ee5f9e3ea110247b32 100644 (file)
@@ -104,7 +104,7 @@ bool DBObjectMap::check(std::ostream &out)
       map<string, bufferlist> got;
       to_get.insert(HEADER_KEY);
       db->get(sys_parent_prefix(header), to_get, &got);
-      if (!got.size()) {
+      if (got.empty()) {
        out << "Missing: seq " << header.parent << std::endl;
        retval = false;
        break;
@@ -553,7 +553,7 @@ int DBObjectMap::_get_header(Header header,
     set<string> to_get;
     to_get.insert(USER_HEADER_KEY);
     int r = db->get(sys_prefix(header), to_get, &out);
-    if (r == 0 && out.size())
+    if (r == 0 && !out.empty())
       break;
     if (r < 0)
       return r;
@@ -563,7 +563,7 @@ int DBObjectMap::_get_header(Header header,
     header = lookup_parent(current);
   }
 
-  if (out.size())
+  if (!out.empty())
     bl->swap(out.begin()->second);
   return 0;
 }
@@ -968,7 +968,7 @@ int DBObjectMap::upgrade()
                      &got);
       if (r < 0)
        return r;
-      if (!got.size())
+      if (got.empty())
        continue; // Moved in a previous transaction
 
       t->rmkeys(USER_PREFIX + header_key(hdr.parent) + SYS_PREFIX,
@@ -1016,7 +1016,7 @@ int DBObjectMap::init(bool do_upgrade)
   int r = db->get(SYS_PREFIX, to_get, &result);
   if (r < 0)
     return r;
-  if (result.size()) {
+  if (!result.empty()) {
     bufferlist::iterator bliter = result.begin()->second.begin();
     state.decode(bliter);
     if (state.v < 1) { // Needs upgrade
@@ -1080,7 +1080,7 @@ DBObjectMap::Header DBObjectMap::_lookup_map_header(const hobject_t &hoid)
   int r = db->get(HOBJECT_TO_SEQ, to_get, &out);
   if (r < 0)
     return Header();
-  if (!out.size())
+  if (out.empty())
     return Header();
   
   Header ret(new _Header(), RemoveMapHeaderOnDelete(this, hoid));
@@ -1123,7 +1123,7 @@ DBObjectMap::Header DBObjectMap::lookup_parent(Header input)
     assert(0);
     return Header();
   }
-  if (out.size() < 1) {
+  if (out.empty()) {
     assert(0);
     return Header();
   }