Commit 687f3fe8 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Switch from VLA to folly::small_vector

Summary: Switch from VLA to folly::small_vector

Reviewed By: yfeldblum, ot

Differential Revision: D23391426

fbshipit-source-id: c6c61f3f0eef5b6e71ad3a639fcfdb4fa1b7268e
parent defe385b
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/String.h> #include <folly/String.h>
#include <folly/portability/Unistd.h> #include <folly/portability/Unistd.h>
#include <folly/small_vector.h>
// debugging helpers // debugging helpers
namespace { namespace {
...@@ -203,7 +204,8 @@ Range<AsyncBase::Op**> AsyncIO::doWait( ...@@ -203,7 +204,8 @@ Range<AsyncBase::Op**> AsyncIO::doWait(
size_t minRequests, size_t minRequests,
size_t maxRequests, size_t maxRequests,
std::vector<AsyncBase::Op*>& result) { std::vector<AsyncBase::Op*>& result) {
io_event events[maxRequests]; size_t constexpr kNumInlineRequests = 16;
folly::small_vector<io_event, kNumInlineRequests> events(maxRequests);
// Unfortunately, Linux AIO doesn't implement io_cancel, so even for // Unfortunately, Linux AIO doesn't implement io_cancel, so even for
// WaitType::CANCEL we have to wait for IO completion. // WaitType::CANCEL we have to wait for IO completion.
...@@ -218,7 +220,7 @@ Range<AsyncBase::Op**> AsyncIO::doWait( ...@@ -218,7 +220,7 @@ Range<AsyncBase::Op**> AsyncIO::doWait(
ctx_, ctx_,
minRequests - count, minRequests - count,
maxRequests - count, maxRequests - count,
events + count, events.data() + count,
/* timeout */ nullptr); // wait forever /* timeout */ nullptr); // wait forever
} while (ret == -EINTR); } while (ret == -EINTR);
// Check as may not be able to recover without leaking events. // Check as may not be able to recover without leaking events.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment