io_uring: Improve file handle allocation
It was originally understood that std::vector<>.reserve() would perform
an exponentially increasing allocation when it ran out of room. Instead
it was behaving linearly with the reserve function.
This changes makes it behave as expected.
Change-Id: Ic0d92232398da727154f6e2ed10d8b44d6f583c0
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/stdplus/io_uring.cpp b/src/stdplus/io_uring.cpp
index 7acf2c7..63b9798 100644
--- a/src/stdplus/io_uring.cpp
+++ b/src/stdplus/io_uring.cpp
@@ -65,8 +65,7 @@
}
io_uring_unregister_files(&ring);
- files.reserve(files.size() + 1);
- files.resize(files.capacity(), -1);
+ files.resize(std::max<size_t>(7, files.size() * 2 + 1), -1);
files[slot] = fd;
CHECK_RET(io_uring_register_files(&ring, files.data(), files.size()),
"io_uring_register_files");