don't allocate strings when str is enought for using as key
This commit is contained in:
parent
2af5c6562d
commit
1b27b69e5a
1 changed files with 3 additions and 3 deletions
|
@ -2320,12 +2320,12 @@ impl crate::Decoder for Decoder {
|
||||||
let name = match self.pop() {
|
let name = match self.pop() {
|
||||||
Json::String(s) => s,
|
Json::String(s) => s,
|
||||||
Json::Object(mut o) => {
|
Json::Object(mut o) => {
|
||||||
let n = match o.remove(&"variant".to_owned()) {
|
let n = match o.remove("variant") {
|
||||||
Some(Json::String(s)) => s,
|
Some(Json::String(s)) => s,
|
||||||
Some(val) => return Err(ExpectedError("String".to_owned(), val.to_string())),
|
Some(val) => return Err(ExpectedError("String".to_owned(), val.to_string())),
|
||||||
None => return Err(MissingFieldError("variant".to_owned())),
|
None => return Err(MissingFieldError("variant".to_owned())),
|
||||||
};
|
};
|
||||||
match o.remove(&"fields".to_string()) {
|
match o.remove("fields") {
|
||||||
Some(Json::Array(l)) => {
|
Some(Json::Array(l)) => {
|
||||||
self.stack.extend(l.into_iter().rev());
|
self.stack.extend(l.into_iter().rev());
|
||||||
}
|
}
|
||||||
|
@ -2365,7 +2365,7 @@ impl crate::Decoder for Decoder {
|
||||||
{
|
{
|
||||||
let mut obj = expect!(self.pop(), Object)?;
|
let mut obj = expect!(self.pop(), Object)?;
|
||||||
|
|
||||||
let value = match obj.remove(&name.to_string()) {
|
let value = match obj.remove(name) {
|
||||||
None => {
|
None => {
|
||||||
// Add a Null and try to parse it as an Option<_>
|
// Add a Null and try to parse it as an Option<_>
|
||||||
// to get None as a default value.
|
// to get None as a default value.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue