]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
KeyValueDBMemory.cc: use empty() instead of size() == 0 73/head
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 26 Feb 2013 10:25:49 +0000 (11:25 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 26 Feb 2013 10:25:49 +0000 (11:25 +0100)
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/test/ObjectMap/KeyValueDBMemory.cc

index 87671ccb1a7acc597ad46caf15eb83fb7e30e563..43fa60c47a1d191012e95976f1ffc28bc78180ee 100644 (file)
@@ -30,7 +30,7 @@ public:
   virtual ~WholeSpaceMemIterator() { }
 
   int seek_to_first() {
-    if (db->db.size() == 0) {
+    if (db->db.empty()) {
       it = db->db.end();
       ready = false;
       return 0;
@@ -42,7 +42,7 @@ public:
 
   int seek_to_first(const string &prefix) {
     it = db->db.lower_bound(make_pair(prefix, ""));
-    if ((db->db.size() == 0) || (it == db->db.end())) {
+    if (db->db.empty() || (it == db->db.end())) {
       it = db->db.end();
       ready = false;
       return 0;
@@ -53,7 +53,7 @@ public:
 
   int seek_to_last() {
     it = db->db.end();
-    if (db->db.size() == 0) {
+    if (db->db.empty()) {
       ready = false;
       return 0;
     }
@@ -68,7 +68,7 @@ public:
     tmp.append(1, (char) 0);
     it = db->db.upper_bound(make_pair(tmp,""));
 
-    if ((db->db.size() == 0) || (it == db->db.end())) {
+    if (db->db.empty() || (it == db->db.end())) {
       seek_to_last();
     }
     else {