event/PollBackend: use unordered_map::emplace() in Add()
This commit is contained in:
parent
0554fe3652
commit
ab5d23da11
@ -35,7 +35,9 @@ PollBackend::Add(int fd, unsigned events, void *obj) noexcept
|
|||||||
e.fd = fd;
|
e.fd = fd;
|
||||||
e.events = events;
|
e.events = events;
|
||||||
e.revents = 0;
|
e.revents = 0;
|
||||||
auto &item = items[fd];
|
|
||||||
|
auto i = items.emplace(fd, Item{}).first;
|
||||||
|
auto &item = i->second;
|
||||||
item.index = index;
|
item.index = index;
|
||||||
item.obj = obj;
|
item.obj = obj;
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user