Problem: use of std::map::insert is inefficient

Solution: use std::map::emplace instead, where available
This commit is contained in:
Simon Giesecke
2017-10-22 17:05:41 +02:00
parent 07eb52cbad
commit a4aceb272b
7 changed files with 17 additions and 18 deletions

View File

@@ -1010,14 +1010,14 @@ void zmq::stream_engine_t::set_handshake_timer ()
bool zmq::stream_engine_t::init_properties (properties_t & properties) {
if (peer_address.empty()) return false;
properties.insert (
std::make_pair (ZMQ_MSG_PROPERTY_PEER_ADDRESS, peer_address));
properties.ZMQ_MAP_INSERT_OR_EMPLACE (
ZMQ_MSG_PROPERTY_PEER_ADDRESS, peer_address);
// Private property to support deprecated SRCFD
std::ostringstream stream;
stream << (int)s;
std::string fd_string = stream.str();
properties.insert(std::make_pair("__fd", fd_string));
properties.ZMQ_MAP_INSERT_OR_EMPLACE ("__fd", ZMQ_MOVE(fd_string));
return true;
}