mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Bravely optimize job_reap
job_reap is now called more often. This optimizes it by doing an early-out if there are no running jobs (common at the prompt) and also skipping the save/restore status, since by inspection we also save and restore the status when running event handlers.
This commit is contained in:
parent
7c153a8307
commit
467755bf4a
16
src/proc.cpp
16
src/proc.cpp
|
@ -688,17 +688,13 @@ static bool process_clean_after_marking(parser_t &parser, bool allow_interactive
|
|||
|
||||
bool job_reap(parser_t &parser, bool allow_interactive) {
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
process_mark_finished_children(parser, false);
|
||||
// Early out for the common case that there are no jobs.
|
||||
if (parser.jobs().empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Preserve the exit status.
|
||||
auto saved_statuses = parser.get_last_statuses();
|
||||
|
||||
bool printed = process_clean_after_marking(parser, allow_interactive);
|
||||
|
||||
// Restore the exit status.
|
||||
parser.set_last_statuses(std::move(saved_statuses));
|
||||
|
||||
return printed;
|
||||
process_mark_finished_children(parser, false /* not block_ok */);
|
||||
return process_clean_after_marking(parser, allow_interactive);
|
||||
}
|
||||
|
||||
/// Get the CPU time for the specified process.
|
||||
|
|
Loading…
Reference in New Issue
Block a user