Merge pull request #532 from sinkuu/redundant_clone

Remove redundant clone
This commit is contained in:
Vincent Prouillet 2018-11-20 11:46:06 +01:00 committed by GitHub
commit 4fa9d89ea8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 13 deletions

View file

@ -80,7 +80,7 @@ impl Section {
pub fn parse(file_path: &Path, content: &str, config: &Config) -> Result<Section> {
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(&section.raw_content);
section.word_count = Some(word_count);
section.reading_time = Some(reading_time);

View file

@ -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);

View file

@ -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"),
}
}

View file

@ -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 &section.file.components {
output_path.push(component);

View file

@ -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<Mutex<imageproc::Processor>>) -> 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);