mirror of
https://github.com/zeromq/libzmq.git
synced 2025-11-09 23:57:50 +01:00
Problem: use of std::map::insert is inefficient
Solution: use std::map::emplace instead, where available
This commit is contained in:
@@ -451,7 +451,8 @@ int zmq::ctx_t::register_endpoint (const char *addr_,
|
||||
{
|
||||
scoped_lock_t locker(endpoints_sync);
|
||||
|
||||
const bool inserted = endpoints.insert (endpoints_t::value_type (std::string (addr_), endpoint_)).second;
|
||||
const bool inserted = endpoints.ZMQ_MAP_INSERT_OR_EMPLACE (addr_,
|
||||
endpoint_).second;
|
||||
if (!inserted) {
|
||||
errno = EADDRINUSE;
|
||||
return -1;
|
||||
@@ -524,7 +525,7 @@ void zmq::ctx_t::pend_connection (const std::string &addr_,
|
||||
if (it == endpoints.end ()) {
|
||||
// Still no bind.
|
||||
endpoint_.socket->inc_seqnum ();
|
||||
pending_connections.insert (pending_connections_t::value_type (addr_, pending_connection));
|
||||
pending_connections.ZMQ_MAP_INSERT_OR_EMPLACE (addr_, pending_connection);
|
||||
} else {
|
||||
// Bind has happened in the mean time, connect directly
|
||||
connect_inproc_sockets(it->second.socket, it->second.options, pending_connection, connect_side);
|
||||
|
||||
Reference in New Issue
Block a user