Skip to content

Commit cc1ba8b

Browse files
authored
Merge pull request #634 from epage/perf
perf: Don't clone when merging
2 parents d37872d + 051628a commit cc1ba8b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/source.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ pub trait Source: Debug {
2020
/// Collects all configuration properties to a provided cache.
2121
fn collect_to(&self, cache: &mut Value) -> Result<()> {
2222
self.collect()?
23-
.iter()
23+
.into_iter()
2424
.for_each(|(key, val)| set_value(cache, key, val));
2525

2626
Ok(())
2727
}
2828
}
2929

30-
fn set_value(cache: &mut Value, key: &str, value: &Value) {
31-
match path::Expression::from_str(key) {
30+
fn set_value(cache: &mut Value, key: String, value: Value) {
31+
match path::Expression::from_str(key.as_str()) {
3232
// Set using the path
33-
Ok(expr) => expr.set(cache, value.clone()),
33+
Ok(expr) => expr.set(cache, value),
3434

3535
// Set directly anyway
36-
_ => path::Expression::root(key.to_owned()).set(cache, value.clone()),
36+
_ => path::Expression::root(key).set(cache, value),
3737
}
3838
}
3939

@@ -64,7 +64,7 @@ pub trait AsyncSource: Debug + Sync {
6464
async fn collect_to(&self, cache: &mut Value) -> Result<()> {
6565
self.collect()
6666
.await?
67-
.iter()
67+
.into_iter()
6868
.for_each(|(key, val)| set_value(cache, key, val));
6969

7070
Ok(())

0 commit comments

Comments
 (0)