Common/Watches: std::move strings where applicable

Allows calling code to move the std::string into the Watch instances,
avoiding copies.
This commit is contained in:
Lioncash
2019-07-08 17:28:07 -04:00
parent 0a7395bfba
commit bc8778203e
7 changed files with 35 additions and 35 deletions

View File

@ -9,12 +9,12 @@
namespace Common::Debug
{
Watch::Watch(u32 address_, const std::string& name_, Watch::State is_enabled_)
: address(address_), name(name_), is_enabled(is_enabled_)
Watch::Watch(u32 address_, std::string name_, State is_enabled_)
: address(address_), name(std::move(name_)), is_enabled(is_enabled_)
{
}
std::size_t Watches::SetWatch(u32 address, const std::string& name)
std::size_t Watches::SetWatch(u32 address, std::string name)
{
const std::size_t size = m_watches.size();
for (std::size_t index = 0; index < size; index++)
@ -25,7 +25,7 @@ std::size_t Watches::SetWatch(u32 address, const std::string& name)
return index;
}
}
m_watches.emplace_back(address, name, Watch::State::Enabled);
m_watches.emplace_back(address, std::move(name), Watch::State::Enabled);
return size;
}
@ -46,10 +46,10 @@ void Watches::UnsetWatch(u32 address)
m_watches.end());
}
void Watches::UpdateWatch(std::size_t index, u32 address, const std::string& name)
void Watches::UpdateWatch(std::size_t index, u32 address, std::string name)
{
m_watches[index].address = address;
m_watches[index].name = name;
m_watches[index].name = std::move(name);
}
void Watches::UpdateWatchAddress(std::size_t index, u32 address)
@ -57,9 +57,9 @@ void Watches::UpdateWatchAddress(std::size_t index, u32 address)
m_watches[index].address = address;
}
void Watches::UpdateWatchName(std::size_t index, const std::string& name)
void Watches::UpdateWatchName(std::size_t index, std::string name)
{
m_watches[index].name = name;
m_watches[index].name = std::move(name);
}
void Watches::EnableWatch(std::size_t index)