mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 07:30:33 +03:00
This is 3% faster because of better use of speculative hardware
This commit is contained in:
parent
30cb5191b0
commit
66ba7b87f0
1 changed files with 6 additions and 2 deletions
|
@ -1340,12 +1340,16 @@ private void quickSortImpl(alias less, Range)(Range r, size_t depth)
|
|||
r.swapAt(pivotIdx, r.length - 1);
|
||||
size_t lessI = size_t.max, greaterI = r.length - 1;
|
||||
|
||||
while (true)
|
||||
outer: for (;;)
|
||||
{
|
||||
alias pred = binaryFun!less;
|
||||
while (pred(r[++lessI], pivot)) {}
|
||||
assert(lessI <= greaterI, "sort: invalid comparison function.");
|
||||
while (greaterI > lessI && pred(pivot, r[--greaterI])) {}
|
||||
for (;;)
|
||||
{
|
||||
if (greaterI == lessI) break outer;
|
||||
if (!pred(pivot, r[--greaterI])) break;
|
||||
}
|
||||
assert(lessI <= greaterI, "sort: invalid comparison function.");
|
||||
if (lessI == greaterI) break;
|
||||
r.swapAt(lessI, greaterI);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue