Revert "Remove custom SkSort algorithms."
This reverts commit 70474c1cb0bc19a025ee678161b633cf57b0a83e.
Reason for revert: bot build failure
Original change's description:
> 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>
TBR=mtklein@google.com,brianosman@google.com,johnstiles@google.com
Change-Id: I1126dd4cda95716dac225ad32d5b0e5cf3f09421
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302447
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/tools/skdiff/skdiff_main.cpp b/tools/skdiff/skdiff_main.cpp
index eec6306..df6e2a1 100644
--- a/tools/skdiff/skdiff_main.cpp
+++ b/tools/skdiff/skdiff_main.cpp
@@ -318,9 +318,9 @@
files->deleteAll();
}
-/// Comparison routine for sorting by file name.
-static int compare_file_name_metrics(const SkString* lhs, const SkString* rhs) {
- return strcmp(lhs->c_str(), rhs->c_str()) < 0;
+/// Comparison routines for qsort, sort by file names.
+static int compare_file_name_metrics(SkString **lhs, SkString **rhs) {
+ return strcmp((*lhs)->c_str(), (*rhs)->c_str());
}
class AutoReleasePixels {
@@ -397,10 +397,12 @@
&comparisonFiles);
if (!baseFiles.isEmpty()) {
- std::sort(baseFiles.begin(), baseFiles.end(), compare_file_name_metrics);
+ qsort(baseFiles.begin(), baseFiles.count(), sizeof(SkString*),
+ SkCastForQSort(compare_file_name_metrics));
}
if (!comparisonFiles.isEmpty()) {
- std::sort(comparisonFiles.begin(), comparisonFiles.end(), compare_file_name_metrics);
+ qsort(comparisonFiles.begin(), comparisonFiles.count(),
+ sizeof(SkString*), SkCastForQSort(compare_file_name_metrics));
}
if (!outputDir.isEmpty()) {