diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-20 12:40:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-20 12:40:16 +0200 |
| commit | 766073aeb4735bda885026731b56919c5cf932ad (patch) | |
| tree | 72e4c064d9c9c983df7ddff5d858c7499634b08c /src/libstd/sys/unix/stack_overflow.rs | |
| parent | f01ffbc7f14c5e80c130d679e99c3507591e4bab (diff) | |
| parent | 23cb1d520bbe943b9dfae54c6a8f2f1fe4748872 (diff) | |
| download | rust-766073aeb4735bda885026731b56919c5cf932ad.tar.gz rust-766073aeb4735bda885026731b56919c5cf932ad.zip | |
Rollup merge of #65551 - sinkuu:cstring_spec, r=sfackler
Avoid realloc in `CString::new` If `&[u8]` or `&str` is given, `CString::new` allocates a new `Vec` with the exact capacity, and then `CString::from_vec_unchecked` calls `.reserve_exact(1)` for nul byte. This PR avoids the reallocation by allocationg `len + 1` bytes beforehand. In microbenchmark this PR speeds up `CString::new(&[u8])` by 30%.
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
