]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd.cc: use empty() instead of size() to check for emptiness
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 14:38:58 +0000 (15:38 +0100)
committerGreg Farnum <greg@inktank.com>
Thu, 14 Feb 2013 18:26:22 +0000 (10:26 -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/rbd.cc

index dd56bc9309e6d917b651e56c34b7cad27948fc4a..d4b2d8b911878c206e43f9998eab54c4d2da1317 100644 (file)
@@ -301,7 +301,7 @@ static int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool lflag,
     if (r < 0)
       return r;
     string lockstr;
-    if (lockers.size()) {
+    if (!lockers.empty()) {
       lockstr = (exclusive) ? "excl" : "shr";
     }
 
@@ -317,7 +317,7 @@ static int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool lflag,
        f->close_section();
       }
       f->dump_int("format", old_format ? 1 : 2);
-      if (lockers.size())
+      if (!lockers.empty())
        f->dump_string("lock_type", exclusive ? "exclusive" : "shared");
       f->close_section();
     } else {
@@ -375,7 +375,7 @@ static int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool lflag,
   if (f) {
     f->close_section();
     f->flush(cout);
-  } else if (names.size()) {
+  } else if (!names.empty()) {
     cout << tbl;
   }