schwab: for-loop instead of while - does not seems like speedup

This commit is contained in:
Richard Thier 2025-05-09 02:30:59 +02:00
parent 19cbf53597
commit 7d1d93a89c

View File

@ -147,12 +147,11 @@ static inline int schwab_partition(
arr[high] = tmphi; arr[high] = tmphi;
/* Aren't inclusive end indices of 4 "blocks" - b0 is smallest vals */ /* Aren't inclusive end indices of 4 "blocks" - b0 is smallest vals */
int b0 = low, b1 = low, b2 = low, b3 = low; int b0 = low, b1 = low, b2 = low;
while(b3 < high) { for(int b3 = low; b3 < high; ++b3) {
/* This I moved to be first for hot code path for constant / smallrange */ /* This I moved to be first to avoid unnecessary curr copy below */
if(arr[b3] >= khi) { if(arr[b3] >= khi) {
++b3;
continue; continue;
} }
@ -169,7 +168,7 @@ static inline int schwab_partition(
arr[b2] = arr[b1]; arr[b2] = arr[b1];
arr[b1] = arr[b0]; arr[b1] = arr[b0];
arr[b0] = curr; arr[b0] = curr;
++b0; ++b1; ++b2; ++b3; ++b0; ++b1; ++b2;
continue; continue;
} }
@ -177,11 +176,11 @@ static inline int schwab_partition(
arr[b3] = arr[b2]; arr[b3] = arr[b2];
arr[b2] = arr[b1]; arr[b2] = arr[b1];
arr[b1] = curr; arr[b1] = curr;
++b1; ++b2; ++b3; ++b1; ++b2;
} else { } else {
arr[b3] = arr[b2]; arr[b3] = arr[b2];
arr[b2] = curr; arr[b2] = curr;
++b2; ++b3; ++b2;
} }
} }
@ -196,7 +195,7 @@ static inline int schwab_partition(
/* Handle output vars as per doc comment */ /* Handle output vars as per doc comment */
*plo = b0; *plo = b0;
*pmid = b1; *pmid = b1;
*phi = b2; /* Because of: [*] */ *phi = b2;
/* There are mid parts to process */ /* There are mid parts to process */
return 1; return 1;