Reduced number of calls to container end method

This commit is contained in:
Simon Giesecke
2018-08-08 21:21:56 +02:00
parent 05e400a3e0
commit 9e2cf35b66
13 changed files with 88 additions and 64 deletions

View File

@@ -786,12 +786,11 @@ int zmq::socket_base_t::connect (const char *addr_)
options.connected = true;
return 0;
}
bool is_single_connect =
const bool is_single_connect =
(options.type == ZMQ_DEALER || options.type == ZMQ_SUB
|| options.type == ZMQ_PUB || options.type == ZMQ_REQ);
if (unlikely (is_single_connect)) {
const endpoints_t::iterator it = _endpoints.find (addr_);
if (it != _endpoints.end ()) {
if (0 != _endpoints.count (addr_)) {
// There is no valid use for multiple connects for SUB-PUB nor
// DEALER-ROUTER nor REQ-REP. Multiple connects produces
// nonsensical results.
@@ -1551,8 +1550,8 @@ void zmq::socket_base_t::pipe_terminated (pipe_t *pipe_)
xpipe_terminated (pipe_);
// Remove pipe from inproc pipes
for (inprocs_t::iterator it = _inprocs.begin (); it != _inprocs.end ();
++it)
for (inprocs_t::iterator it = _inprocs.begin (), end = _inprocs.end ();
it != end; ++it)
if (it->second == pipe_) {
_inprocs.erase (it);
break;
@@ -1790,12 +1789,13 @@ int zmq::routing_socket_base_t::xsetsockopt (int option_,
void zmq::routing_socket_base_t::xwrite_activated (pipe_t *pipe_)
{
const out_pipes_t::iterator end = _out_pipes.end ();
out_pipes_t::iterator it;
for (it = _out_pipes.begin (); it != _out_pipes.end (); ++it)
for (it = _out_pipes.begin (); it != end; ++it)
if (it->second.pipe == pipe_)
break;
zmq_assert (it != _out_pipes.end ());
zmq_assert (it != end);
zmq_assert (!it->second.active);
it->second.active = true;
}