git: 935c26dbe3a6 - stable/14 - libkern: Drop incorrect qsort optimization
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Aug 2025 19:22:10 UTC
The branch stable/14 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=935c26dbe3a6ce77cda9bd802fa45cdb938610a6
commit 935c26dbe3a6ce77cda9bd802fa45cdb938610a6
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-08-15 18:01:02 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-08-27 18:49:58 +0000
libkern: Drop incorrect qsort optimization
See 5205b32de3fb for details.
PR: 287089
MFC after: 1 week
Reviewed by: jlduran
Differential Revision: https://reviews.freebsd.org/D51919
(cherry picked from commit ef8f3e913156aa268e07ae1daa68e3bc3f1c4d29)
---
sys/libkern/qsort.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/sys/libkern/qsort.c b/sys/libkern/qsort.c
index 2707d2ecb738..71cdceaa33dc 100644
--- a/sys/libkern/qsort.c
+++ b/sys/libkern/qsort.c
@@ -115,11 +115,10 @@ qsort(void *a, size_t n, size_t es, cmp_t *cmp)
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
size_t d1, d2;
int cmp_result;
- int swaptype_long, swaptype_int, swap_cnt;
+ int swaptype_long, swaptype_int;
loop: SWAPINIT(long, a, es);
SWAPINIT(int, a, es);
- swap_cnt = 0;
if (n < 7) {
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
for (pl = pm;
@@ -148,7 +147,6 @@ loop: SWAPINIT(long, a, es);
for (;;) {
while (pb <= pc && (cmp_result = CMP(thunk, pb, a)) <= 0) {
if (cmp_result == 0) {
- swap_cnt = 1;
swap(pa, pb);
pa += es;
}
@@ -156,7 +154,6 @@ loop: SWAPINIT(long, a, es);
}
while (pb <= pc && (cmp_result = CMP(thunk, pc, a)) >= 0) {
if (cmp_result == 0) {
- swap_cnt = 1;
swap(pc, pd);
pd -= es;
}
@@ -165,18 +162,9 @@ loop: SWAPINIT(long, a, es);
if (pb > pc)
break;
swap(pb, pc);
- swap_cnt = 1;
pb += es;
pc -= es;
}
- if (swap_cnt == 0) { /* Switch to insertion sort */
- for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
- for (pl = pm;
- pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
- pl -= es)
- swap(pl, pl - es);
- return;
- }
pn = (char *)a + n * es;
d1 = MIN(pa - (char *)a, pb - pa);