-
Couldn't load subscription status.
- Fork 13.9k
Avoid allocations in Decoder::read_str.
#37064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
r? @erickt (rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @eddyb |
|
(This is a carry-over of #37022 because I borked my git clone.) |
|
@bors r+ |
|
📌 Commit d6117f8 has been approved by |
`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.
|
@eddyb: bleh, I pushed with some uncommitted changes. New version should be better. |
|
@bors r+ |
|
📌 Commit b043e11 has been approved by |
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.
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.
opaque::Decoder::read_stris very hot withinrustcdue to its use inthe reading of crate metadata, and it currently returns a
String. Thiscommit changes it to instead return a
Cow<str>, which avoids a heapallocation.
This change reduces the number of calls to
mallocby almost 10% insome benchmarks.
This is a [breaking-change] to libserialize.