From: Kefu Chai Date: Fri, 3 Jan 2020 12:45:05 +0000 (+0800) Subject: include/interval_set: use prefix operator for non-trivial iterator X-Git-Tag: v15.1.0~203^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1cbde6dacab8fc8c767f2d04ce2871912b43d8fa;p=ceph.git include/interval_set: use prefix operator for non-trivial iterator for better performance. no need to create a temporary instance of iterator and throw it away Signed-off-by: Kefu Chai --- diff --git a/src/include/interval_set.h b/src/include/interval_set.h index f2f79f7c07af..5b2b90d87ac1 100644 --- a/src/include/interval_set.h +++ b/src/include/interval_set.h @@ -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() &&