From: Danny Al-Gaaf Date: Wed, 13 Feb 2013 16:38:56 +0000 (+0100) Subject: cls_kvs.cc: use !empty() instead of 'size() > 0' to check for emptiness X-Git-Tag: v0.58~66^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc0a108773e0e4c5e9a17422825de986d2256e9a;p=ceph.git cls_kvs.cc: use !empty() instead of 'size() > 0' 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/key_value_store/cls_kvs.cc b/src/key_value_store/cls_kvs.cc index fad46f0ca607e..8c70a63f54b3e 100644 --- a/src/key_value_store/cls_kvs.cc +++ b/src/key_value_store/cls_kvs.cc @@ -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);