diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-11-07 17:39:36 +0100 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2015-11-07 17:45:14 +0100 |
| commit | 35fd1bab5e727061248c7810ca1fbe81e336d019 (patch) | |
| tree | 7e0ec48d4a05927939f8b0e5759b922b7e345172 /src/libstd/sys/unix/stack_overflow.rs | |
| parent | 792a9f12cff83186a5426bc6e713fbc11261a4b1 (diff) | |
| download | rust-35fd1bab5e727061248c7810ca1fbe81e336d019.tar.gz rust-35fd1bab5e727061248c7810ca1fbe81e336d019.zip | |
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 sorted. 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. Reduces 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
