Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace insert with emplace #4712

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <set>

#include "options.hpp"
#include "blob.hpp"
#include "err.hpp"
#include "macros.hpp"

Expand Down Expand Up @@ -758,8 +759,7 @@ int zmq::options_t::setsockopt (int option_,
if (key.compare (0, 2, "X-") == 0
&& key.length () <= UCHAR_MAX) {
std::string val = s.substr (pos + 1, s.length ());
app_metadata.insert (
std::pair<std::string, std::string> (key, val));
app_metadata.ZMQ_MAP_INSERT_OR_EMPLACE (key, val);
return 0;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/poller_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "precompiled.hpp"
#include "poller_base.hpp"
#include "i_poll_events.hpp"
#include "blob.hpp"
#include "err.hpp"

zmq::poller_base_t::~poller_base_t ()
Expand All @@ -28,7 +29,7 @@ void zmq::poller_base_t::add_timer (int timeout_, i_poll_events *sink_, int id_)
{
uint64_t expiration = _clock.now_ms () + timeout_;
timer_info_t info = {sink_, id_};
_timers.insert (timers_t::value_type (expiration, info));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (expiration, info);
}

void zmq::poller_base_t::cancel_timer (i_poll_events *sink_, int id_)
Expand Down
10 changes: 5 additions & 5 deletions src/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "precompiled.hpp"
#include "timers.hpp"
#include "blob.hpp"
#include "err.hpp"

#include <algorithm>
Expand Down Expand Up @@ -30,7 +31,7 @@ int zmq::timers_t::add (size_t interval_, timers_timer_fn handler_, void *arg_)

uint64_t when = _clock.now_ms () + interval_;
timer_t timer = {++_next_timer_id, interval_, handler_, arg_};
_timers.insert (timersmap_t::value_type (when, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);

return timer.timer_id;
}
Expand Down Expand Up @@ -79,7 +80,7 @@ int zmq::timers_t::set_interval (int timer_id_, size_t interval_)
timer.interval = interval_;
uint64_t when = _clock.now_ms () + interval_;
_timers.erase (it);
_timers.insert (timersmap_t::value_type (when, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);

return 0;
}
Expand All @@ -97,7 +98,7 @@ int zmq::timers_t::reset (int timer_id_)
timer_t timer = it->second;
uint64_t when = _clock.now_ms () + timer.interval;
_timers.erase (it);
_timers.insert (timersmap_t::value_type (when, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);

return 0;
}
Expand Down Expand Up @@ -147,8 +148,7 @@ int zmq::timers_t::execute ()

timer.handler (timer.timer_id, timer.arg);

_timers.insert (
timersmap_t::value_type (now + timer.interval, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (now + timer.interval, timer);
}
}
_timers.erase (begin, it);
Expand Down
Loading