mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-08 01:56:16 +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>,
|
handles: &mut Vec<WaitHandleRef>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// Has a job already completed?
|
// Has a job already completed?
|
||||||
// TODO: we can avoid traversing this list if searching by pid.
|
|
||||||
let mut matched = false;
|
let mut matched = false;
|
||||||
let wait_handles: &mut WaitHandleStore = &mut parser.mut_wait_handles();
|
let wait_handles: &mut WaitHandleStore = &mut parser.mut_wait_handles();
|
||||||
for wh in wait_handles.iter() {
|
match query {
|
||||||
if wait_handle_matches(query, wh) {
|
WaitHandleQuery::Pid(pid) => {
|
||||||
handles.push(wh.clone());
|
if let Some(wh) = wait_handles.get_by_pid(pid) {
|
||||||
matched = true;
|
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