]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/common.cc. use !empty() to check for non-emptiness
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 13 Feb 2013 18:13:51 +0000 (19:13 +0100)
committerGreg Farnum <greg@inktank.com>
Thu, 14 Feb 2013 18:27:40 +0000 (10:27 -0800)
Use !empty() instead of size() to check for non-emptiness for
performance reasons.

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

index 13aff67ac6e3ee5016228f81da7c935eec30b4ed..514d33d902fffeb3bef029edeaa9ed614f797f79 100644 (file)
@@ -260,7 +260,7 @@ int do_command(CephToolCtx *ctx,
   pending_tell_pgid = false;
   reply = false;
   
-  if (cmd.size() > 0 && cmd[0] == "tell") {
+  if (!cmd.empty() && cmd[0] == "tell") {
     if (cmd.size() == 1) {
       cerr << "no tell target specified" << std::endl;
       return -EINVAL;
@@ -272,7 +272,7 @@ int do_command(CephToolCtx *ctx,
     pending_cmd.erase(pending_cmd.begin(), pending_cmd.begin() + 2);
     pending_tell = true;
   }
-  if (cmd.size() > 0 && cmd[0] == "pg") {
+  if (!cmd.empty() && cmd[0] == "pg") {
     if (cmd.size() == 1) {
       cerr << "pg requires at least one argument" << std::endl;
       return -EINVAL;
@@ -580,7 +580,7 @@ bool Admin::ms_dispatch(Message *m) {
 void Admin::ms_handle_connect(Connection *con) {
   if (con->get_peer_type() == CEPH_ENTITY_TYPE_MON) {
     ctx->lock.Lock();
-    if (pending_cmd.size())
+    if (!pending_cmd.empty())
       send_command(ctx);
     ctx->lock.Unlock();
   }
@@ -592,7 +592,7 @@ bool Admin::ms_handle_reset(Connection *con)
   if (con == command_con) {
     command_con->put();
     command_con = NULL;
-    if (pending_cmd.size())
+    if (!pending_cmd.empty())
       send_command(ctx);
     return true;
   }