From 6cf0114fe3e85bcc5234965bf1290e40b6d286a5 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sat, 11 Mar 2023 15:03:41 +0100 Subject: [PATCH] Avoid some unneessary cloning Change-Id: Ifbd5ef80a72fefc6b224a1801a696eb3c2e32371 --- src/sync_ref.rs | 2 +- src/validator.rs | 4 ++-- src/wsgi.rs | 12 ++++++------ src/yattag.rs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sync_ref.rs b/src/sync_ref.rs index 20b4f0daa..217940d0c 100644 --- a/src/sync_ref.rs +++ b/src/sync_ref.rs @@ -62,7 +62,7 @@ pub fn our_main( for path in paths { let url = format!("{url}{path}"); let dest = ctx.get_abspath(&format!("workdir/refs/{path}")); - dests.push(dest.clone()); + dests.push(dest.to_string()); if ctx.get_file_system().path_exists(&dest) { continue; } diff --git a/src/validator.rs b/src/validator.rs index 12c386019..dc9a12818 100644 --- a/src/validator.rs +++ b/src/validator.rs @@ -283,8 +283,8 @@ pub fn our_main( stream: &mut dyn Write, ctx: &context::Context, ) -> anyhow::Result<()> { - let yaml_path = argv[1].clone(); - let data = ctx.get_file_system().read_to_string(&yaml_path)?; + let yaml_path = &argv[1]; + let data = ctx.get_file_system().read_to_string(yaml_path)?; let mut errors: Vec = Vec::new(); if data.contains('\t') { diff --git a/src/wsgi.rs b/src/wsgi.rs index bb5d16f68..6f56b9de7 100644 --- a/src/wsgi.rs +++ b/src/wsgi.rs @@ -1370,16 +1370,16 @@ fn handle_main( /// Determines the HTML title for a given function and relation name. fn get_html_title(request_uri: &str) -> String { let tokens: Vec = request_uri.split('/').map(|i| i.to_string()).collect(); - let mut function: String = "".into(); - let mut relation_name: String = "".into(); + let mut function = ""; + let mut relation_name = ""; if tokens.len() > 3 { - function = tokens[2].clone(); - relation_name = tokens[3].clone(); + function = &tokens[2]; + relation_name = &tokens[3]; } - match function.as_str() { + match function { "missing-housenumbers" => format!( " - {}", - tr("{0} missing house numbers").replace("{0}", &relation_name) + tr("{0} missing house numbers").replace("{0}", relation_name) ), "missing-streets" => format!(" - {} {}", relation_name, tr("missing streets")), "street-housenumbers" => format!(" - {} {}", relation_name, tr("existing house numbers")), diff --git a/src/yattag.rs b/src/yattag.rs index 468ef8f01..4307cf5ad 100644 --- a/src/yattag.rs +++ b/src/yattag.rs @@ -40,7 +40,7 @@ impl Doc { /// Gets the escaped value. pub fn get_value(&self) -> String { - self.value.borrow().clone() + self.value.borrow().to_string() } /// Appends escaped content to the value.