]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #37064 - nnethercote:read_str, r=eddyb
authorAlex Crichton <alex@alexcrichton.com>
Wed, 12 Oct 2016 17:15:27 +0000 (10:15 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 12 Oct 2016 21:07:56 +0000 (14:07 -0700)
Avoid allocations in `Decoder::read_str`.

`opaque::Decoder::read_str` is very hot within `rustc` due to its use in
the reading of crate metadata, and it currently returns a `String`. This
commit changes it to instead return a `Cow<str>`, which avoids a heap
allocation.

This change reduces the number of calls to `malloc` by almost 10% in
some benchmarks.

This is a [breaking-change] to libserialize.


Trivial merge