]> git.lizzy.rs Git - rust.git/commit
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)
commitf05bd1b41ddda779032f4c5c8e30bf640129832f
tree20136a8f6a2215e22703c51ba54c78426c3837fe
parenta0ad6616fc2244eea66c6adadd35f899b170505f
parentb043e11de2eb2c60f7bfec5e15960f537b229e20
Rollup merge of #37064 - nnethercote:read_str, r=eddyb

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.