[libc-commits] [PATCH] D130310: [libc] Don't call user comparator function for equal pointers
Alex Brachet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Jul 22 10:03:32 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e2d5071ffd7: [libc] Don't call user comparator function for equal pointers (authored by abrachet).
Herald added a project: libc-project.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130310/new/
https://reviews.llvm.org/D130310
Files:
libc/src/stdlib/qsort.cpp
Index: libc/src/stdlib/qsort.cpp
===================================================================
--- libc/src/stdlib/qsort.cpp
+++ libc/src/stdlib/qsort.cpp
@@ -42,6 +42,10 @@
}
int elem_compare(size_t i, const uint8_t *other) const {
+ // An element must compare equal to itself so we don't need to consult the
+ // user provided comparator.
+ if (get(i) == other)
+ return 0;
return compare(get(i), other);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130310.446887.patch
Type: text/x-patch
Size: 447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220722/d519989b/attachment.bin>
More information about the libc-commits
mailing list