From c4f1c0799fd2fcc83346a0b8b3c3477750c4db7c Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Wed, 13 Feb 2013 16:49:53 +0100 Subject: [PATCH] cls/rbd/cls_rbd.cc: use !empty() instead of 'size() > 0' 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 --- src/cls/rbd/cls_rbd.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index a55be8c7d83..3088f38178b 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -1116,7 +1116,7 @@ int get_snapcontext(cls_method_context_t hctx, bufferlist *in, bufferlist *out) snapid_t snap_id = snap_id_from_key(*it); snap_ids.push_back(snap_id); } - if (keys.size() > 0) + if (!keys.empty()) last_read = *(keys.rbegin()); } while (r == max_read); @@ -1269,7 +1269,7 @@ int snapshot_add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) } } - if (vals.size() > 0) + if (!vals.empty()) last_read = vals.rbegin()->first; } while (r == RBD_MAX_KEYS_READ); @@ -1717,7 +1717,7 @@ int dir_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) if (images.size() >= max_return) break; } - if (vals.size() > 0) { + if (!vals.empty()) { last_read = dir_key_for_name(images.rbegin()->first); } }