summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rc/plan9.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-11-01 11:23:39 -0800
committerOri Bernstein <ori@eigenstate.org>2020-11-01 11:23:39 -0800
commitb5086c1863fe10faf48ab675f503e562ec8dfcf0 (patch)
treeeda10b4fc690a80d2d742cfbe85c870cdbf11435 /sys/src/cmd/rc/plan9.c
parent51b22d8548e61d3807b8b94e09d84f116ca0eb1c (diff)
libc: recurse on smaller half of array
Our qsort has an optimization to recurse on one half of the array, and do a tail call on the other half. Unfortunately, the condition deciding which half of the array to recurse on was wrong, so we were recursing on the larger half of the array and iterating on the smaller half. This meant that if we picked the partition poorly, we were pessimizing our stack usage instead of optimizing it. This change reduces our stack usage from O(n) to O(log(n)) for poorly chosen pivots.
Diffstat (limited to 'sys/src/cmd/rc/plan9.c')
0 files changed, 0 insertions, 0 deletions