Skip to content

Commit 5cf0867

Browse files
committed
Speed up procfs scanning
1 parent fab04c5 commit 5cf0867

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/kill.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,7 @@ pub fn choose_victim(
2323

2424
let mut processes = fs::read_dir("/proc/")?
2525
.filter_map(|e| e.ok())
26-
.filter_map(|entry| {
27-
entry
28-
.path()
29-
.file_name()
30-
.unwrap_or_else(|| OsStr::new("0"))
31-
.to_str()
32-
.unwrap_or("0")
33-
.trim()
34-
.parse::<u32>()
35-
.ok()
36-
})
26+
.filter_map(|entry| entry.file_name().to_str()?.trim().parse::<u32>().ok())
3727
.filter(|pid| *pid > 1)
3828
.filter_map(|pid| Process::from_pid(pid, proc_buf).ok());
3929

0 commit comments

Comments
 (0)