Remove custom SkSort algorithms.
SortBench shows that SkTQSort and SkTHeapSort are inferior to std::sort.
The difference is small on randomized inputs, but quite significant for
semi-ordered inputs (forward/backward/repeated). There doesn't seem to
to be any compelling advantage to SkTQSort.
Nanobench results: https://screenshot.googleplex.com/9JOLV1d6Z0u
(These performance numbers are from an optimized build my local machine;
it's possible that we might see different results on the test bots.)
Change-Id: Iaf19563041547eae7de2953be249129108f093b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302295
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/pathops/SkPathOpsTSect.cpp b/src/pathops/SkPathOpsTSect.cpp
index 674c635..59b5059 100644
--- a/src/pathops/SkPathOpsTSect.cpp
+++ b/src/pathops/SkPathOpsTSect.cpp
@@ -1754,13 +1754,12 @@
}
void finish(SkIntersections* intersections) const {
- SkSTArray<SkDCubic::kMaxIntersections * 3,
- const SkClosestRecord*, true> closestPtrs;
+ SkSTArray<SkDCubic::kMaxIntersections * 3, const SkClosestRecord*, true> closestPtrs;
for (int index = 0; index < fUsed; ++index) {
closestPtrs.push_back(&fClosest[index]);
}
- SkTQSort<const SkClosestRecord >(closestPtrs.begin(), closestPtrs.end()
- - 1);
+ std::sort(closestPtrs.begin(), closestPtrs.end(),
+ [](const SkClosestRecord* a, const SkClosestRecord* b) { return *a < *b; });
for (int index = 0; index < fUsed; ++index) {
const SkClosestRecord* test = closestPtrs[index];
test->addIntersection(intersections);