From 5a02d3808184d4d2714c7ab4a608a7b698624b35 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 23 Sep 2013 20:32:31 +0200 Subject: [PATCH] small optimization in event manager --- src/event_manager.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/event_manager.cc b/src/event_manager.cc index 13cd9bd6..3d0c9f31 100644 --- a/src/event_manager.cc +++ b/src/event_manager.cc @@ -52,8 +52,8 @@ void EventManager::handle_next_events() events.reserve(m_fd_watchers.size()); for (auto& watcher : m_fd_watchers) events.emplace_back(pollfd{ watcher->fd(), POLLIN | POLLPRI, 0 }); - std::vector forced = m_forced_fd; - m_forced_fd.clear(); + std::vector forced; + std::swap(forced, m_forced_fd); poll(events.data(), events.size(), timeout_ms); for (size_t i = 0; i < events.size(); ++i) { @@ -82,7 +82,6 @@ void EventManager::handle_next_events() void EventManager::force_signal(int fd) { m_forced_fd.push_back(fd); - } }