about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-11-13 01:44:58 +0000
committerbors <bors@rust-lang.org>2015-11-13 01:44:58 +0000
commit8a813e088cf2169f1e1ff5a18c6b26d847885e3d (patch)
treedf4a21a59722f43a6270e48509cdcc8d74173fbf /src/libstd/sys/unix/stack_overflow.rs
parentd5fde83ae7ec0d9ff7ebbcb9391a1d71a81a3f1d (diff)
parent0f5e30d16004334cac1a25dbeefc0cfb886a404d (diff)
downloadrust-8a813e088cf2169f1e1ff5a18c6b26d847885e3d.tar.gz
rust-8a813e088cf2169f1e1ff5a18c6b26d847885e3d.zip
Auto merge of #29675 - bluss:merge-sort-fastpath, r=huonw
sort: Fast path for already sorted data

When merging two sorted blocks `left` and `right` if the last element in
`left` is <= the first in `right`, the blocks are already in sorted order.

Add this as an additional fast path by simply copying the whole left
block into the output and advancing the left pointer. The right block is
then treated the same way by the already present logic in the merge
loop.

Can reduce runtime of .sort() to less than 50% of the previous, if the data
was already perfectly sorted. Sorted data with a few swaps are also
sorted quicker than before. The overhead of one comparison per merge
seems to be negligible.
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions