Kernel: Reduce kmallocing in all_processes() and all_pids().

This commit is contained in:
Andreas Kling 2019-04-16 00:37:35 +02:00
parent 2533e0b57b
commit 1debc0a78c
Notes: sideshowbarker 2024-07-19 14:41:40 +09:00

View file

@ -52,6 +52,7 @@ Vector<pid_t> Process::all_pids()
{
Vector<pid_t> pids;
InterruptDisabler disabler;
pids.ensure_capacity(g_processes->size_slow());
for (auto* process = g_processes->head(); process; process = process->next())
pids.append(process->pid());
return pids;
@ -61,6 +62,7 @@ Vector<Process*> Process::all_processes()
{
Vector<Process*> processes;
InterruptDisabler disabler;
processes.ensure_capacity(g_processes->size_slow());
for (auto* process = g_processes->head(); process; process = process->next())
processes.append(process);
return processes;