about summary refs log tree commit diff
diff options
context:
space:
mode:
authorklensy <klensy@users.noreply.github.com>2021-12-07 12:54:35 +0300
committerklensy <klensy@users.noreply.github.com>2021-12-07 12:54:35 +0300
commit1b27b69e5a5464484e63f7eb324376c901fd3692 (patch)
tree77dd5006e47a350ff118fa57fe481c226917dfc6
parent2af5c6562deed1878000e791f2cb21b981a53959 (diff)
downloadrust-1b27b69e5a5464484e63f7eb324376c901fd3692.tar.gz
rust-1b27b69e5a5464484e63f7eb324376c901fd3692.zip
don't allocate strings when str is enought for using as key
-rw-r--r--compiler/rustc_serialize/src/json.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs
index df78e1bcbf6..cb9df3c3389 100644
--- a/compiler/rustc_serialize/src/json.rs
+++ b/compiler/rustc_serialize/src/json.rs
@@ -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.