Skip to content

Commit

Permalink
Merge pull request #634 from epage/perf
Browse files Browse the repository at this point in the history
perf: Don't clone when merging
  • Loading branch information
epage authored Jan 10, 2025
2 parents d37872d + 051628a commit cc1ba8b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ pub trait Source: Debug {
/// Collects all configuration properties to a provided cache.
fn collect_to(&self, cache: &mut Value) -> Result<()> {
self.collect()?
.iter()
.into_iter()
.for_each(|(key, val)| set_value(cache, key, val));

Ok(())
}
}

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

// Set directly anyway
_ => path::Expression::root(key.to_owned()).set(cache, value.clone()),
_ => path::Expression::root(key).set(cache, value),
}
}

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

Ok(())
Expand Down

0 comments on commit cc1ba8b

Please sign in to comment.