about summary refs log tree commit diff
path: root/src/test/debuginfo/enum-thinlto.rs
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-11-15 11:04:31 +0100
committerGitHub <noreply@github.com>2018-11-15 11:04:31 +0100
commit3b404349407e7a63730078a2d81d6c86f7f965b3 (patch)
treefa6ae39cb023c21718c05f3e86fd8012b348f3de /src/test/debuginfo/enum-thinlto.rs
parentd7c833b7ef4e2bec35e8753dcde398828f387aaf (diff)
parent19aa10132cc727c8561730ab096b21d14507c81d (diff)
downloadrust-3b404349407e7a63730078a2d81d6c86f7f965b3.tar.gz
rust-3b404349407e7a63730078a2d81d6c86f7f965b3.zip
Rollup merge of #55530 - ljedrz:speed_up_String_from_utf16, r=SimonSapin
Speed up String::from_utf16

Collecting into a `Result` is idiomatic, but not necessarily fast due to rustc not being able to preallocate for the resulting collection. This is fine in case of an error, but IMO we should optimize for the common case, i.e. a successful conversion.

This changes the behavior of `String::from_utf16` from collecting into a `Result` to pushing to a preallocated `String` in a loop.

According to [my simple benchmark](https://gist.github.com/ljedrz/953a3fb74058806519bd4d640d6f65ae) this change makes `String::from_utf16` around **twice** as fast.
Diffstat (limited to 'src/test/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions