From ab5d23da1106c16e366f9e278478f7bdca0d01d5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 30 Oct 2020 16:23:28 +0100 Subject: [PATCH] event/PollBackend: use unordered_map::emplace() in Add() --- src/event/PollBackend.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/event/PollBackend.cxx b/src/event/PollBackend.cxx index 88a6568b0..a505816d0 100644 --- a/src/event/PollBackend.cxx +++ b/src/event/PollBackend.cxx @@ -35,7 +35,9 @@ PollBackend::Add(int fd, unsigned events, void *obj) noexcept e.fd = fd; e.events = events; e.revents = 0; - auto &item = items[fd]; + + auto i = items.emplace(fd, Item{}).first; + auto &item = i->second; item.index = index; item.obj = obj; return true;