Skip to content

Commit 1b27b69

Browse files
committed
don't allocate strings when str is enought for using as key
1 parent 2af5c65 commit 1b27b69

File tree

1 file changed

+3
-3
lines changed
  • compiler/rustc_serialize/src

1 file changed

+3
-3
lines changed

compiler/rustc_serialize/src/json.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2320,12 +2320,12 @@ impl crate::Decoder for Decoder {
23202320
let name = match self.pop() {
23212321
Json::String(s) => s,
23222322
Json::Object(mut o) => {
2323-
let n = match o.remove(&"variant".to_owned()) {
2323+
let n = match o.remove("variant") {
23242324
Some(Json::String(s)) => s,
23252325
Some(val) => return Err(ExpectedError("String".to_owned(), val.to_string())),
23262326
None => return Err(MissingFieldError("variant".to_owned())),
23272327
};
2328-
match o.remove(&"fields".to_string()) {
2328+
match o.remove("fields") {
23292329
Some(Json::Array(l)) => {
23302330
self.stack.extend(l.into_iter().rev());
23312331
}
@@ -2365,7 +2365,7 @@ impl crate::Decoder for Decoder {
23652365
{
23662366
let mut obj = expect!(self.pop(), Object)?;
23672367

2368-
let value = match obj.remove(&name.to_string()) {
2368+
let value = match obj.remove(name) {
23692369
None => {
23702370
// Add a Null and try to parse it as an Option<_>
23712371
// to get None as a default value.

0 commit comments

Comments
 (0)