From 1cbde6dacab8fc8c767f2d04ce2871912b43d8fa Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 3 Jan 2020 20:45:05 +0800 Subject: [PATCH] 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 --- src/include/interval_set.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/include/interval_set.h b/src/include/interval_set.h index f2f79f7c07af4..5b2b90d87ac1b 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() && -- 2.39.5