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
Notes:
sideshowbarker
2024-07-17 20:04:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b27b22a68c0
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;
|
||||
TRY(fds_info.try_ensure_capacity(params.nfds));
|
||||
|
||||
for (size_t i = 0; i < params.nfds; i++) {
|
||||
auto& pfd = fds_copy[i];
|
||||
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;
|
||||
if (pfd.events & POLLWRBAND)
|
||||
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();
|
||||
|
|
Loading…
Add table
Reference in a new issue