avoid unnecessary copies by using std::move
This commit is contained in:
parent
799768641f
commit
0cc0178ab5
@ -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))
|
||||
{ ; }
|
||||
|
||||
|
||||
|
@ -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))
|
||||
{ ; }
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
2
time.cpp
2
time.cpp
@ -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)
|
||||
{ ; }
|
||||
|
Loading…
Reference in New Issue
Block a user