diff --git a/src/event/PollBackend.cxx b/src/event/PollBackend.cxx index a3fad40c3..0ce3f73be 100644 --- a/src/event/PollBackend.cxx +++ b/src/event/PollBackend.cxx @@ -24,17 +24,22 @@ PollBackend::PollBackend() noexcept = default; PollBackend::~PollBackend() noexcept = default; +static constexpr auto +MakePollfd(int fd, short events) noexcept +{ + struct pollfd pfd{}; + pfd.fd = fd; + pfd.events = events; + return pfd; +} + bool PollBackend::Add(int fd, unsigned events, void *obj) noexcept { assert(items.find(fd) == items.end()); const std::size_t index = poll_events.size(); - poll_events.resize(index + 1); - auto &e = poll_events[index]; - e.fd = fd; - e.events = events; - e.revents = 0; + poll_events.push_back(MakePollfd(fd, events)); items.emplace(std::piecewise_construct, std::forward_as_tuple(fd),