mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #91626 - klensy:json-less-alloc, r=petrochenkov
rustc_serialize: don't allocate `String`s as key for `BTreeMap`, when `str` is enough
This commit is contained in:
commit
6d6d0899c8
@ -2320,12 +2320,12 @@ impl crate::Decoder for Decoder {
|
||||
let name = match self.pop() {
|
||||
Json::String(s) => s,
|
||||
Json::Object(mut o) => {
|
||||
let n = match o.remove(&"variant".to_owned()) {
|
||||
let n = match o.remove("variant") {
|
||||
Some(Json::String(s)) => s,
|
||||
Some(val) => return Err(ExpectedError("String".to_owned(), val.to_string())),
|
||||
None => return Err(MissingFieldError("variant".to_owned())),
|
||||
};
|
||||
match o.remove(&"fields".to_string()) {
|
||||
match o.remove("fields") {
|
||||
Some(Json::Array(l)) => {
|
||||
self.stack.extend(l.into_iter().rev());
|
||||
}
|
||||
@ -2365,7 +2365,7 @@ impl crate::Decoder for Decoder {
|
||||
{
|
||||
let mut obj = expect!(self.pop(), Object)?;
|
||||
|
||||
let value = match obj.remove(&name.to_string()) {
|
||||
let value = match obj.remove(name) {
|
||||
None => {
|
||||
// Add a Null and try to parse it as an Option<_>
|
||||
// to get None as a default value.
|
||||
|
Loading…
Reference in New Issue
Block a user