summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-10-30 16:23:28 +0100
committerMax Kellermann <max@musicpd.org>2020-10-30 16:24:32 +0100
commitab5d23da1106c16e366f9e278478f7bdca0d01d5 (patch)
tree6555cd9fa89e0db276a57228f436f9c22a9c4b8c
parent0554fe3652890faae5f2b27ff6eb804c3440ddf6 (diff)
event/PollBackend: use unordered_map::emplace() in Add()
-rw-r--r--src/event/PollBackend.cxx4
1 files changed, 3 insertions, 1 deletions
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;