mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
Kernel: Allocate entire SelectBlocker::FDVector at once
Use try_ensure_capacity() + unchecked_append() instead of repeatedly doing try_append().
This commit is contained in:
parent
a12e19c015
commit
b27b22a68c
1 changed files with 3 additions and 1 deletions
|
@ -45,6 +45,8 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> use
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::SelectBlocker::FDVector fds_info;
|
Thread::SelectBlocker::FDVector fds_info;
|
||||||
|
TRY(fds_info.try_ensure_capacity(params.nfds));
|
||||||
|
|
||||||
for (size_t i = 0; i < params.nfds; i++) {
|
for (size_t i = 0; i < params.nfds; i++) {
|
||||||
auto& pfd = fds_copy[i];
|
auto& pfd = fds_copy[i];
|
||||||
auto description = TRY(fds().open_file_description(pfd.fd));
|
auto description = TRY(fds().open_file_description(pfd.fd));
|
||||||
|
@ -57,7 +59,7 @@ ErrorOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> use
|
||||||
block_flags |= BlockFlags::ReadPriority;
|
block_flags |= BlockFlags::ReadPriority;
|
||||||
if (pfd.events & POLLWRBAND)
|
if (pfd.events & POLLWRBAND)
|
||||||
block_flags |= BlockFlags::WritePriority;
|
block_flags |= BlockFlags::WritePriority;
|
||||||
TRY(fds_info.try_append({ move(description), block_flags }));
|
fds_info.unchecked_append({ move(description), block_flags });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* current_thread = Thread::current();
|
auto* current_thread = Thread::current();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue