]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #56548 - Lucretiel:string-extend-optimize, r=sfackler
authorPietro Albini <pietro@pietroalbini.org>
Thu, 6 Dec 2018 06:49:01 +0000 (07:49 +0100)
committerGitHub <noreply@github.com>
Thu, 6 Dec 2018 06:49:01 +0000 (07:49 +0100)
commite9e92d53ade5767e533338bc6b2aaa70083c30ec
treeabf1fdf1e56c1f55d60c880e5c046d67299fdf84
parent9e7ff567501f48b62a4ee6b441ae4b3d3afcb38e
parent811a2bfe5332081d7145de6c488ea7f6c5cf42a5
Rollup merge of #56548 - Lucretiel:string-extend-optimize, r=sfackler

Optimized string FromIterator + Extend impls

I noticed that there was a lost opportunity to reuse string buffers in `FromIterator<String>` and `FromIterator<Cow<str>>`; updated the implementations to use these. In practice this translates to at least one fewer allocation when using these APIs.

Additionally, rewrote `Extend` implementations to use `iter.for_each`, which (supposedly) helps the compiler optimize those loops (because iterator adapters are encouraged to provide optimized implementations of `fold` and `try_fold`.
src/liballoc/string.rs