]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/LevelDBStore: fix merge loop
authorSage Weil <sage@inktank.com>
Mon, 3 Jun 2013 01:07:34 +0000 (18:07 -0700)
committerSage Weil <sage@inktank.com>
Mon, 3 Jun 2013 01:08:11 +0000 (18:08 -0700)
We were double-incrementing p, both in the for statement and in the
body.  While we are here, drop the unnecessary else's.

Signed-off-by: Sage Weil <sage@inktank.com>
src/os/LevelDBStore.cc

index 4e4e0e5c1777ee358d67026881c0d0ae9c3e003e..0b1ea5c19134ac4250f489aa08844a23d574490d 100644 (file)
@@ -229,26 +229,27 @@ void LevelDBStore::compact_range_async(const string& start, const string& end)
   // try to merge adjacent ranges.  this is O(n), but the queue should
   // be short.  note that we do not cover all overlap cases and merge
   // opportunities here, but we capture the ones we currently need.
-  list< pair<string,string> >::iterator p;
-  for (p = compact_queue.begin(); p != compact_queue.end(); ++p) {
+  list< pair<string,string> >::iterator p = compact_queue.begin();
+  while (p != compact_queue.end()) {
     if (p->first == start && p->second == end) {
       // dup; no-op
       return;
-    } else if (p->first <= end && p->first > start) {
+    }
+    if (p->first <= end && p->first > start) {
       // merge with existing range to the right
       compact_queue.push_back(make_pair(start, p->second));
       compact_queue.erase(p);
       logger->inc(l_leveldb_compact_queue_merge);
       break;
-    } else if (p->second >= start && p->second < end) {
+    }
+    if (p->second >= start && p->second < end) {
       // merge with existing range to the left
       compact_queue.push_back(make_pair(p->first, end));
       compact_queue.erase(p);
       logger->inc(l_leveldb_compact_queue_merge);
       break;
-    } else {
-      ++p;
     }
+    ++p;
   }
   if (p == compact_queue.end()) {
     // no merge, new entry.