From 692103bff4a4efcc8ee8c127d5ead0b4d06ed204 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Mon, 19 Nov 2018 23:04:22 +0900 Subject: [PATCH] Remove redundant clone --- components/library/src/content/section.rs | 2 +- components/rendering/src/markdown.rs | 2 +- components/rendering/src/shortcode.rs | 6 +++--- components/site/src/lib.rs | 8 +++----- components/templates/src/global_fns/mod.rs | 6 +++--- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/components/library/src/content/section.rs b/components/library/src/content/section.rs index 05c1b319..76f66183 100644 --- a/components/library/src/content/section.rs +++ b/components/library/src/content/section.rs @@ -80,7 +80,7 @@ impl Section { pub fn parse(file_path: &Path, content: &str, config: &Config) -> Result
{ let (meta, content) = split_section_content(file_path, content)?; let mut section = Section::new(file_path, meta); - section.raw_content = content.clone(); + section.raw_content = content; let (word_count, reading_time) = get_reading_analytics(§ion.raw_content); section.word_count = Some(word_count); section.reading_time = Some(reading_time); diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index 7ec4fc1e..c21e58b7 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -31,7 +31,7 @@ pub struct Rendered { // means we will have example, example-1, example-2 etc fn find_anchor(anchors: &[String], name: String, level: u8) -> String { if level == 0 && !anchors.contains(&name) { - return name.to_string(); + return name; } let new_anchor = format!("{}-{}", name, level + 1); diff --git a/components/rendering/src/shortcode.rs b/components/rendering/src/shortcode.rs index 294eee3e..d292e867 100644 --- a/components/rendering/src/shortcode.rs +++ b/components/rendering/src/shortcode.rs @@ -20,9 +20,9 @@ lazy_static! { fn replace_string_markers(input: &str) -> String { match input.chars().next().unwrap() { - '"' => input.replace('"', "").to_string(), - '\'' => input.replace('\'', "").to_string(), - '`' => input.replace('`', "").to_string(), + '"' => input.replace('"', ""), + '\'' => input.replace('\'', ""), + '`' => input.replace('`', ""), _ => unreachable!("How did you even get there"), } } diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index bee3a4ca..3df0686d 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -771,7 +771,7 @@ impl Site { pages.par_sort_unstable_by(sort_actual_pages_by_date); - context.insert("last_build_date", &pages[0].meta.date.clone().map(|d| d.to_string())); + context.insert("last_build_date", &pages[0].meta.date.clone()); // limit to the last n elements if the limit is set; otherwise use all. let num_entries = self.config.rss_limit.unwrap_or(pages.len()); let p = pages @@ -794,7 +794,7 @@ impl Site { let feed = &render_template("rss.xml", &self.tera, &context, &self.config.theme)?; if let Some(ref base) = base_path { - let mut output_path = self.output_path.clone().to_path_buf(); + let mut output_path = self.output_path.clone(); for component in base.components() { output_path.push(component); if !output_path.exists() { @@ -812,9 +812,7 @@ impl Site { /// Renders a single section pub fn render_section(&self, section: &Section, render_pages: bool) -> Result<()> { ensure_directory_exists(&self.output_path)?; - let public = self.output_path.clone(); - - let mut output_path = public.to_path_buf(); + let mut output_path = self.output_path.clone(); for component in §ion.file.components { output_path.push(component); diff --git a/components/templates/src/global_fns/mod.rs b/components/templates/src/global_fns/mod.rs index 2ba5aad5..5c8deb5a 100644 --- a/components/templates/src/global_fns/mod.rs +++ b/components/templates/src/global_fns/mod.rs @@ -184,8 +184,8 @@ pub fn make_get_taxonomy_url(all_taxonomies: &[Taxonomy]) -> GlobalFn { } }; - if let Some(ref permalink) = container.get(&name) { - return Ok(to_value(permalink.clone()).unwrap()); + if let Some(permalink) = container.get(&name) { + return Ok(to_value(permalink).unwrap()); } Err(format!("`get_taxonomy_url`: couldn't find `{}` in `{}` taxonomy", name, kind).into()) @@ -226,7 +226,7 @@ pub fn make_resize_image(imageproc: Arc>) -> GlobalF return Err(format!("`resize_image`: Cannot find path: {}", path).into()); } - let imageop = imageproc::ImageOp::from_args(path.clone(), &op, width, height, quality) + let imageop = imageproc::ImageOp::from_args(path, &op, width, height, quality) .map_err(|e| format!("`resize_image`: {}", e))?; let url = imageproc.insert(imageop);