aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/json
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/json')
-rw-r--r--crates/shirabe/src/json/json_file.rs4
-rw-r--r--crates/shirabe/src/json/json_manipulator.rs20
2 files changed, 12 insertions, 12 deletions
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs
index 91e0d380..868745ef 100644
--- a/crates/shirabe/src/json/json_file.rs
+++ b/crates/shirabe/src/json/json_file.rs
@@ -228,7 +228,7 @@ impl JsonFile {
if self.path == "php://memory" {
file_put_contents(
&self.path,
- Self::encode_with_options(&hash, options.clone()).as_bytes(),
+ Self::encode_with_options(&hash, options).as_bytes(),
);
return Ok(());
@@ -469,7 +469,7 @@ impl JsonFile {
if options.pretty_print && options.indent != Self::INDENT_DEFAULT {
// Pretty printing and not using default indentation
- let indent_owned = options.indent.clone();
+ let indent_owned = options.indent;
return Preg::replace_callback(
php_regex!(r"#^ {4,}#m"),
move |m: &indexmap::IndexMap<
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(