Skip to content

Commit

Permalink
Avoid temporary allocation for PathBuf
Browse files Browse the repository at this point in the history
PathBuf is to Path what String is to str. This code here only needs a
Path since join() allocates a new PathBuf. Thus, this gets rid of a
temporary allocation for the original PathBuf.

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed Nov 18, 2023
1 parent 8cca65e commit 6c5e94d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ fn find_udevd() -> Option<PathBuf> {
PathBuf::from("/lib/systemd/systemd-udevd"),
];
let path = env::var("PATH").unwrap_or_else(|_| String::new());
let path_candidates = path.split(':').map(|dir| PathBuf::from(dir).join("udevd"));
let path_candidates = path.split(':').map(|dir| Path::new(dir).join("udevd"));

static_candidates
.into_iter()
Expand Down

0 comments on commit 6c5e94d

Please sign in to comment.