diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-25 16:16:33 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-25 16:17:10 +0900 |
| commit | 432472808051cb4f1bb9517b858dbc810aaa5a63 (patch) | |
| tree | 4c58b97942853ea2c3f58368203fa93187746cf8 /crates/shirabe/src/json/json_manipulator.rs | |
| parent | d4608662f28b9a5135986b1702afe3199957eabe (diff) | |
| download | php-shirabe-432472808051cb4f1bb9517b858dbc810aaa5a63.tar.gz php-shirabe-432472808051cb4f1bb9517b858dbc810aaa5a63.tar.zst php-shirabe-432472808051cb4f1bb9517b858dbc810aaa5a63.zip | |
refactor: replace redundant clones with moves
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/json/json_manipulator.rs')
| -rw-r--r-- | crates/shirabe/src/json/json_manipulator.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs index e501940c..3647e846 100644 --- a/crates/shirabe/src/json/json_manipulator.rs +++ b/crates/shirabe/src/json/json_manipulator.rs @@ -676,13 +676,13 @@ impl JsonManipulator { if decoded.as_array().and_then(|a| a.get(main_node)).is_none() { if let Some(ref sub) = sub_name { let mut inner: IndexMap<String, PhpMixed> = IndexMap::new(); - inner.insert(sub.clone(), value.clone()); + inner.insert(sub.clone(), value); let mut outer: IndexMap<String, PhpMixed> = IndexMap::new(); - outer.insert(name_owned.clone(), PhpMixed::Array(inner)); + outer.insert(name_owned, PhpMixed::Array(inner)); self.add_main_key(main_node, PhpMixed::Array(outer))?; } else { let mut outer: IndexMap<String, PhpMixed> = IndexMap::new(); - outer.insert(name_owned.clone(), value.clone()); + outer.insert(name_owned, value); self.add_main_key(main_node, PhpMixed::Array(outer))?; } @@ -717,14 +717,14 @@ impl JsonManipulator { ); if let Some(cm) = child { let content_str = children[cm.value_pos..cm.value_end].to_string(); - let mut value_local = value.clone(); - if sub_name.is_some() { + let mut value_local = value; + if let Some(sub_name) = sub_name { let mut cur_val = json_decode(&content_str, true).unwrap_or(PhpMixed::Null); if !is_array(&cur_val) { cur_val = PhpMixed::Array(IndexMap::new()); } if let Some(arr) = cur_val.as_array_mut() { - arr.insert(sub_name.clone().unwrap(), value_local.clone()); + arr.insert(sub_name, value_local.clone()); } value_local = cur_val; } @@ -754,7 +754,7 @@ impl JsonManipulator { .unwrap_or_default(); let content_present = leading_match.get("content").is_some(); if content_present { - let mut value_local = value.clone(); + let mut value_local = value; if let Some(ref sub) = sub_name { let mut wrap: IndexMap<String, PhpMixed> = IndexMap::new(); wrap.insert(sub.clone(), value_local.clone()); @@ -780,7 +780,7 @@ impl JsonManipulator { &children, ); } else { - whitespace = leading_space.clone(); + whitespace = leading_space; children = Preg::replace( format!("#^{{{}#", whitespace), &addcslashes( @@ -799,7 +799,7 @@ impl JsonManipulator { ); } } else { - let mut value_local = value.clone(); + let mut value_local = value; if let Some(ref sub) = sub_name { let mut wrap: IndexMap<String, PhpMixed> = IndexMap::new(); wrap.insert(sub.clone(), value_local.clone()); @@ -1084,7 +1084,7 @@ impl JsonManipulator { &children, ); } else { - whitespace = leading_whitespace.clone(); + whitespace = leading_whitespace; children = Preg::replace( format!("#^\\[{}#", whitespace), &addcslashes( |
