about summary refs log tree commit diff
path: root/pkgs/profpatsch/nman
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-02-17 18:27:12 +0100
committersternenseemann <sternenseemann@systemli.org>2021-02-25 19:52:33 +0100
commita696d200515195bf6dffaf3822a36393d26d6292 (patch)
treed18db5120623e1782abd6b7563c449bf2b04716e /pkgs/profpatsch/nman
parentd2fdd7b76124fd08ee0c783d6aeb8dcd58b4e959 (diff)
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.
Diffstat (limited to 'pkgs/profpatsch/nman')
-rw-r--r--pkgs/profpatsch/nman/nman.rs15
1 files changed, 6 insertions, 9 deletions
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,
         }