From 3750a8964c0424387cdf545a6d1a4f7dd5035147 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Fri, 26 Feb 2016 17:48:50 +0300 Subject: [PATCH] removed redundant clones --- util/src/keys/geth_import.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/src/keys/geth_import.rs b/util/src/keys/geth_import.rs index 61df88589..2ee3c987c 100644 --- a/util/src/keys/geth_import.rs +++ b/util/src/keys/geth_import.rs @@ -63,12 +63,13 @@ pub fn import_geth_key(secret_store: &mut SecretStore, geth_keyfile_path: &Path) let mut buf = String::new(); try!(file.read_to_string(&mut buf)); - let mut json = match Json::from_str(&buf) { - Ok(parsed_json) => try!(parsed_json.as_object().ok_or(ImportError::FormatError)).clone(), + let mut json_result = Json::from_str(&buf); + let mut json = match json_result { + Ok(ref mut parsed_json) => try!(parsed_json.as_object_mut().ok_or(ImportError::FormatError)), Err(_) => { return Err(ImportError::FormatError); } }; let crypto_object = try!(json.get("Crypto").and_then(|crypto| crypto.as_object()).ok_or(ImportError::FormatError)).clone(); - json.insert("crypto".to_owned(), Json::Object(crypto_object.clone())); + json.insert("crypto".to_owned(), Json::Object(crypto_object)); json.remove("Crypto"); match KeyFileContent::load(&Json::Object(json.clone())) { Ok(key_file) => try!(secret_store.import_key(key_file)),