From a696d200515195bf6dffaf3822a36393d26d6292 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Wed, 17 Feb 2021 18:27:12 +0100 Subject: pkgs/profpatsch/nman: clone path instead of resetting it Just copy path instead of having a harder to maintain reset mechanism. Copying strings is not really a performance concern in this case. --- pkgs/profpatsch/nman/nman.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'pkgs/profpatsch/nman') diff --git a/pkgs/profpatsch/nman/nman.rs b/pkgs/profpatsch/nman/nman.rs index 016b97b1..426807a9 100644 --- a/pkgs/profpatsch/nman/nman.rs +++ b/pkgs/profpatsch/nman/nman.rs @@ -215,22 +215,19 @@ fn build_man_page<'a>(drv: DrvWithOutput, section: Option<&str>, page: &str, tem Some((_, "")) => continue, Some(("man", s)) => { // we have a valid man dir, check if it contains our page - path.push(dir.as_os_str()); - path.push(page); + let mut page_path = path.clone(); + page_path.push(dir.as_os_str()); + page_path.push(page); // for nix we almost always have .{section}.gz as extension, // but traditionally plain .{section} is common and possible for ext in EXTENSIONS.iter() { - path.set_extension(format!("{}{}", s, ext)); + page_path.set_extension(format!("{}{}", s, ext)); - if path.exists() { - return Ok(Some(path)); + if page_path.exists() { + return Ok(Some(page_path)); } } - - // reset the PathBuf if we didn't find anything - path.pop(); // page - path.pop(); // section directory }, _ => continue, } -- cgit 1.4.1