avoid unnecessary copies by using std::move

This commit is contained in:
Danny Robson 2018-07-24 15:47:21 +10:00
parent 799768641f
commit 0cc0178ab5
4 changed files with 5 additions and 5 deletions

View File

@ -465,7 +465,7 @@ invalid_key::what (void) const noexcept
///////////////////////////////////////////////////////////////////////////////
invalid_value::invalid_value (std::string _value):
m_value (_value)
m_value (std::move (_value))
{ ; }

View File

@ -38,5 +38,5 @@ json::parse_error::what (void) const noexcept
///////////////////////////////////////////////////////////////////////////////
json::key_error::key_error (std::string _key):
error (to_string (util::format::printf ("missing key '%s'", _key))),
key (_key)
key (std::move (_key))
{ ; }

View File

@ -23,13 +23,13 @@ using util::stringid;
//-----------------------------------------------------------------------------
stringid::id_t
stringid::add (const std::string key) {
stringid::add (std::string key) {
auto pos = m_map.find (key);
if (pos != m_map.end ())
throw std::invalid_argument ("duplicate stringid key");
id_t id = m_map.size ();
m_map[key] = id;
m_map.insert ({ std::move (key), id });
return id;
}

View File

@ -101,7 +101,7 @@ util::rate_limiter::poll (void)
///////////////////////////////////////////////////////////////////////////////
util::polled_duration::polled_duration (std::string name, uint64_t interval):
m_name (name),
m_name (std::move (name)),
m_interval (interval),
m_next (nanoseconds () + interval)
{ ; }