diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 00:04:26 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 09:27:37 -0800 |
| commit | 3e5257f68f2411cbef54569a9340c5f22b2e65bb (patch) | |
| tree | 4d478116204cb1f37513955e88795bbcd1f2a2a2 /src/rustllvm/RustWrapper.cpp | |
| parent | 0191dce41dcb18253581bb28d1e09867e3b9d759 (diff) | |
| parent | e40a81b37bf11ae6f7fc3294ac17230eabaaab03 (diff) | |
| download | rust-3e5257f68f2411cbef54569a9340c5f22b2e65bb.tar.gz rust-3e5257f68f2411cbef54569a9340c5f22b2e65bb.zip | |
rollup merge of #20079: SimonSapin/string_push_ascii_fast_path
`String::push(&mut self, ch: char)` currently has a single code path that calls `Char::encode_utf8`. This adds a fast path for ASCII `char`s, which are represented as a single byte in UTF-8.
Benchmarks of stage1 libcollections at the intermediate commit show that the fast path very significantly improves the performance of repeatedly pushing an ASCII `char`, but does not significantly affect the performance for a non-ASCII `char` (where the fast path is not taken).
```
bench_push_char_one_byte 59552 ns/iter (+/- 2132) = 167 MB/s
bench_push_char_one_byte_with_fast_path 6563 ns/iter (+/- 658) = 1523 MB/s
bench_push_char_two_bytes 71520 ns/iter (+/- 3541) = 279 MB/s
bench_push_char_two_bytes_with_slow_path 71452 ns/iter (+/- 4202) = 279 MB/s
bench_push_str_one_byte 38910 ns/iter (+/- 2477) = 257 MB/s
```
A benchmark of pushing a one-byte-long `&str` is added for comparison, but its performance [has varied a lot lately](https://github.com/rust-lang/rust/pull/19640#issuecomment-67741561). (When the input is fixed, `s.push_str("x")` could be used just as well as `s.push('x')`.)
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
