]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/interval_set: use prefix operator for non-trivial iterator
authorKefu Chai <kchai@redhat.com>
Fri, 3 Jan 2020 12:45:05 +0000 (20:45 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 15 Jan 2020 03:11:54 +0000 (11:11 +0800)
for better performance. no need to create a temporary instance of
iterator and throw it away

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/interval_set.h

index f2f79f7c07af4f011677db853f925197632a73a8..5b2b90d87ac1bab6c783729a8211bfd119ad27fc 100644 (file)
@@ -208,9 +208,9 @@ class interval_set {
     auto p = m.lower_bound(start);  // p->first >= start
     if (p != m.begin() &&
         (p == m.end() || p->first > start)) {
-      p--;   // might overlap?
+      --p;   // might overlap?
       if (p->first + p->second <= start)
-        p++; // it doesn't.
+        ++p; // it doesn't.
     }
     return p;
   }
@@ -219,9 +219,9 @@ class interval_set {
     auto p = m.lower_bound(start);
     if (p != m.begin() &&
         (p == m.end() || p->first > start)) {
-      p--;   // might overlap?
+      --p;   // might overlap?
       if (p->first + p->second <= start)
-        p++; // it doesn't.
+        ++p; // it doesn't.
     }
     return p;
   }
@@ -230,9 +230,9 @@ class interval_set {
     auto p = m.lower_bound(start);
     if (p != m.begin() &&
         (p == m.end() || p->first > start)) {
-      p--;   // might touch?
+      --p;   // might touch?
       if (p->first + p->second < start)
-        p++; // it doesn't.
+        ++p; // it doesn't.
     }
     return p;
   }
@@ -241,9 +241,9 @@ class interval_set {
     auto p = m.lower_bound(start);
     if (p != m.begin() &&
         (p == m.end() || p->first > start)) {
-      p--;   // might touch?
+      --p;   // might touch?
       if (p->first + p->second < start)
-        p++; // it doesn't.
+        ++p; // it doesn't.
     }
     return p;
   }
@@ -468,7 +468,7 @@ class interval_set {
         p->second += len;               // append to end
         
         auto n = p;
-        n++;
+        ++n;
        if (pstart)
          *pstart = p->first;
         if (n != m.end() &&