Update SkTQSort to use half-open ranges.
C++ algorithms have largely standardized on a [begin, end) half-open
range, as seen in standard library containers. SkTQSort now adheres to
this model, and takes vec.begin() and vec.end() as its inputs.
To avoid confusion between inclusive and half-open ranges inside the
implementation, internal helper functions now take "left" and "count"
arguments instead of "left"/"right" or "begin"/"end". This avoids any
ambiguity.
(Although performance was not the main goal, this CL appears to
slightly improve our sorting benchmark on my machine.)
Change-Id: I5e96b6730be96cf23d001ee0915c69764b2c024a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302579
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/src/pathops/SkPathOpsCommon.cpp b/src/pathops/SkPathOpsCommon.cpp
index a4d0fcd..fb90df1 100644
--- a/src/pathops/SkPathOpsCommon.cpp
+++ b/src/pathops/SkPathOpsCommon.cpp
@@ -165,7 +165,7 @@
return false;
}
if (count > 1) {
- SkTQSort<SkOpContour>(list.begin(), list.end() - 1);
+ SkTQSort<SkOpContour>(list.begin(), list.end());
}
contour = list[0];
SkOpContourHead* contourHead = static_cast<SkOpContourHead*>(contour);