diff options
| author | Kevin Ballard <kevin@sb.org> | 2015-01-19 10:15:17 -0800 |
|---|---|---|
| committer | Kevin Ballard <kevin@sb.org> | 2015-01-19 11:11:07 -0800 |
| commit | c384ee18fcb55274682e8a9a24608bfc825bedce (patch) | |
| tree | e3dd72dae67d23000b0cebcac81b85ce16a41faf /src/libstd/sys/unix/stack_overflow.rs | |
| parent | a913fc64d2f179dfcf7b11895f5b6c7c24d6979c (diff) | |
| download | rust-c384ee18fcb55274682e8a9a24608bfc825bedce.tar.gz rust-c384ee18fcb55274682e8a9a24608bfc825bedce.zip | |
Don't reallocate when capacity is already equal to length
`Vec::shrink_to_fit()` may be called on vectors that are already the
correct length. Calling out to `reallocate()` in this case is a bad idea
because there is no guarantee that `reallocate()` won't allocate a new
buffer anyway, and based on performance seen in external benchmarks, it
seems likely that it is in fact reallocating a new buffer.
Before:
test string::tests::bench_exact_size_shrink_to_fit ... bench: 45 ns/iter (+/- 2)
After:
test string::tests::bench_exact_size_shrink_to_fit ... bench: 26 ns/iter (+/- 1)
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
