]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_kvs.cc: use !empty() instead of 'size() > 0' to check for emptiness
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 16:38:56 +0000 (17:38 +0100)
committerGreg Farnum <greg@inktank.com>
Thu, 14 Feb 2013 18:27:38 +0000 (10:27 -0800)
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/key_value_store/cls_kvs.cc

index fad46f0ca607eb419423bafa53873ecdbc6e997b..8c70a63f54b3e93538ab9a1194d582b14cc1091e 100644 (file)
@@ -56,7 +56,7 @@ static int get_idata_from_key(cls_method_context_t hctx, const string &key,
     CLS_LOG(20, "%s is already in the index: %d", key.c_str(), r);
     bufferlist::iterator b = raw_val.begin();
     idata.decode(b);
-    if (kvmap.size() != 0) {
+    if (!kvmap.empty()) {
       bufferlist::iterator b = kvmap.begin()->second.begin();
       next_idata.decode(b);
     }
@@ -120,7 +120,7 @@ static int get_next_idata(cls_method_context_t hctx, const index_data &idata,
     return r;
   }
 
-  if (kvs.size() > 0) {
+  if (!kvs.empty()) {
     out_data.kdata.parse(kvs.begin()->first);
     bufferlist::iterator b = kvs.begin()->second.begin();
     out_data.decode(b);