mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-07 23:21:45 +08:00
Avoid traversing wait handle list if searching by PID
This commit is contained in:
parent
53dc7772eb
commit
943adf4dd0
|
@ -36,13 +36,22 @@ fn find_wait_handles(
|
|||
handles: &mut Vec<WaitHandleRef>,
|
||||
) -> bool {
|
||||
// Has a job already completed?
|
||||
// TODO: we can avoid traversing this list if searching by pid.
|
||||
let mut matched = false;
|
||||
let wait_handles: &mut WaitHandleStore = &mut parser.mut_wait_handles();
|
||||
for wh in wait_handles.iter() {
|
||||
if wait_handle_matches(query, wh) {
|
||||
handles.push(wh.clone());
|
||||
matched = true;
|
||||
match query {
|
||||
WaitHandleQuery::Pid(pid) => {
|
||||
if let Some(wh) = wait_handles.get_by_pid(pid) {
|
||||
handles.push(wh);
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
for wh in wait_handles.iter() {
|
||||
if wait_handle_matches(query, wh) {
|
||||
handles.push(wh.clone());
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user