mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
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:
parent
0a7395bfba
commit
bc8778203e
@ -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)
|
||||
|
@ -24,19 +24,19 @@ struct Watch
|
||||
std::string name;
|
||||
State is_enabled;
|
||||
|
||||
Watch(u32 address, const std::string& name, State is_enabled);
|
||||
Watch(u32 address, std::string name, State is_enabled);
|
||||
};
|
||||
|
||||
class Watches
|
||||
{
|
||||
public:
|
||||
std::size_t SetWatch(u32 address, const std::string& name);
|
||||
std::size_t SetWatch(u32 address, std::string name);
|
||||
const Watch& GetWatch(std::size_t index) const;
|
||||
const std::vector<Watch>& GetWatches() const;
|
||||
void UnsetWatch(u32 address);
|
||||
void UpdateWatch(std::size_t index, u32 address, const std::string& name);
|
||||
void UpdateWatch(std::size_t index, u32 address, std::string name);
|
||||
void UpdateWatchAddress(std::size_t index, u32 address);
|
||||
void UpdateWatchName(std::size_t index, const std::string& name);
|
||||
void UpdateWatchName(std::size_t index, std::string name);
|
||||
void EnableWatch(std::size_t index);
|
||||
void DisableWatch(std::size_t index);
|
||||
bool HasEnabledWatch(u32 address) const;
|
||||
|
@ -22,13 +22,13 @@ protected:
|
||||
|
||||
public:
|
||||
// Watches
|
||||
virtual std::size_t SetWatch(u32 address, const std::string& name = "") = 0;
|
||||
virtual std::size_t SetWatch(u32 address, std::string name = "") = 0;
|
||||
virtual const Common::Debug::Watch& GetWatch(std::size_t index) const = 0;
|
||||
virtual const std::vector<Common::Debug::Watch>& GetWatches() const = 0;
|
||||
virtual void UnsetWatch(u32 address) = 0;
|
||||
virtual void UpdateWatch(std::size_t index, u32 address, const std::string& name) = 0;
|
||||
virtual void UpdateWatch(std::size_t index, u32 address, std::string name) = 0;
|
||||
virtual void UpdateWatchAddress(std::size_t index, u32 address) = 0;
|
||||
virtual void UpdateWatchName(std::size_t index, const std::string& name) = 0;
|
||||
virtual void UpdateWatchName(std::size_t index, std::string name) = 0;
|
||||
virtual void EnableWatch(std::size_t index) = 0;
|
||||
virtual void DisableWatch(std::size_t index) = 0;
|
||||
virtual bool HasEnabledWatch(u32 address) const = 0;
|
||||
|
@ -44,9 +44,9 @@ void PPCPatches::Patch(std::size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t PPCDebugInterface::SetWatch(u32 address, const std::string& name)
|
||||
std::size_t PPCDebugInterface::SetWatch(u32 address, std::string name)
|
||||
{
|
||||
return m_watches.SetWatch(address, name);
|
||||
return m_watches.SetWatch(address, std::move(name));
|
||||
}
|
||||
|
||||
const Common::Debug::Watch& PPCDebugInterface::GetWatch(std::size_t index) const
|
||||
@ -64,9 +64,9 @@ void PPCDebugInterface::UnsetWatch(u32 address)
|
||||
m_watches.UnsetWatch(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UpdateWatch(std::size_t index, u32 address, const std::string& name)
|
||||
void PPCDebugInterface::UpdateWatch(std::size_t index, u32 address, std::string name)
|
||||
{
|
||||
return m_watches.UpdateWatch(index, address, name);
|
||||
return m_watches.UpdateWatch(index, address, std::move(name));
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UpdateWatchAddress(std::size_t index, u32 address)
|
||||
@ -74,9 +74,9 @@ void PPCDebugInterface::UpdateWatchAddress(std::size_t index, u32 address)
|
||||
return m_watches.UpdateWatchAddress(index, address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UpdateWatchName(std::size_t index, const std::string& name)
|
||||
void PPCDebugInterface::UpdateWatchName(std::size_t index, std::string name)
|
||||
{
|
||||
return m_watches.UpdateWatchName(index, name);
|
||||
return m_watches.UpdateWatchName(index, std::move(name));
|
||||
}
|
||||
|
||||
void PPCDebugInterface::EnableWatch(std::size_t index)
|
||||
@ -121,7 +121,7 @@ void PPCDebugInterface::SetPatch(u32 address, u32 value)
|
||||
|
||||
void PPCDebugInterface::SetPatch(u32 address, std::vector<u8> value)
|
||||
{
|
||||
m_patches.SetPatch(address, value);
|
||||
m_patches.SetPatch(address, std::move(value));
|
||||
}
|
||||
|
||||
const std::vector<Common::Debug::MemoryPatch>& PPCDebugInterface::GetPatches() const
|
||||
|
@ -22,13 +22,13 @@ class PPCDebugInterface final : public Common::DebugInterface
|
||||
public:
|
||||
PPCDebugInterface() {}
|
||||
// Watches
|
||||
std::size_t SetWatch(u32 address, const std::string& name = "") override;
|
||||
std::size_t SetWatch(u32 address, std::string name = "") override;
|
||||
const Common::Debug::Watch& GetWatch(std::size_t index) const override;
|
||||
const std::vector<Common::Debug::Watch>& GetWatches() const override;
|
||||
void UnsetWatch(u32 address) override;
|
||||
void UpdateWatch(std::size_t index, u32 address, const std::string& name) override;
|
||||
void UpdateWatch(std::size_t index, u32 address, std::string name) override;
|
||||
void UpdateWatchAddress(std::size_t index, u32 address) override;
|
||||
void UpdateWatchName(std::size_t index, const std::string& name) override;
|
||||
void UpdateWatchName(std::size_t index, std::string name) override;
|
||||
void EnableWatch(std::size_t index) override;
|
||||
void DisableWatch(std::size_t index) override;
|
||||
bool HasEnabledWatch(u32 address) const override;
|
||||
|
@ -20,9 +20,9 @@ void DSPPatches::Patch(std::size_t index)
|
||||
PanicAlert("Patch functionality not supported in DSP module.");
|
||||
}
|
||||
|
||||
std::size_t DSPDebugInterface::SetWatch(u32 address, const std::string& name)
|
||||
std::size_t DSPDebugInterface::SetWatch(u32 address, std::string name)
|
||||
{
|
||||
return m_watches.SetWatch(address, name);
|
||||
return m_watches.SetWatch(address, std::move(name));
|
||||
}
|
||||
|
||||
const Common::Debug::Watch& DSPDebugInterface::GetWatch(std::size_t index) const
|
||||
@ -40,9 +40,9 @@ void DSPDebugInterface::UnsetWatch(u32 address)
|
||||
m_watches.UnsetWatch(address);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::UpdateWatch(std::size_t index, u32 address, const std::string& name)
|
||||
void DSPDebugInterface::UpdateWatch(std::size_t index, u32 address, std::string name)
|
||||
{
|
||||
return m_watches.UpdateWatch(index, address, name);
|
||||
return m_watches.UpdateWatch(index, address, std::move(name));
|
||||
}
|
||||
|
||||
void DSPDebugInterface::UpdateWatchAddress(std::size_t index, u32 address)
|
||||
@ -50,9 +50,9 @@ void DSPDebugInterface::UpdateWatchAddress(std::size_t index, u32 address)
|
||||
return m_watches.UpdateWatchAddress(index, address);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::UpdateWatchName(std::size_t index, const std::string& name)
|
||||
void DSPDebugInterface::UpdateWatchName(std::size_t index, std::string name)
|
||||
{
|
||||
return m_watches.UpdateWatchName(index, name);
|
||||
return m_watches.UpdateWatchName(index, std::move(name));
|
||||
}
|
||||
|
||||
void DSPDebugInterface::EnableWatch(std::size_t index)
|
||||
@ -97,7 +97,7 @@ void DSPDebugInterface::SetPatch(u32 address, u32 value)
|
||||
|
||||
void DSPDebugInterface::SetPatch(u32 address, std::vector<u8> value)
|
||||
{
|
||||
m_patches.SetPatch(address, value);
|
||||
m_patches.SetPatch(address, std::move(value));
|
||||
}
|
||||
|
||||
const std::vector<Common::Debug::MemoryPatch>& DSPDebugInterface::GetPatches() const
|
||||
|
@ -23,13 +23,13 @@ class DSPDebugInterface final : public Common::DebugInterface
|
||||
public:
|
||||
DSPDebugInterface() {}
|
||||
// Watches
|
||||
std::size_t SetWatch(u32 address, const std::string& name = "") override;
|
||||
std::size_t SetWatch(u32 address, std::string name = "") override;
|
||||
const Common::Debug::Watch& GetWatch(std::size_t index) const override;
|
||||
const std::vector<Common::Debug::Watch>& GetWatches() const override;
|
||||
void UnsetWatch(u32 address) override;
|
||||
void UpdateWatch(std::size_t index, u32 address, const std::string& name) override;
|
||||
void UpdateWatch(std::size_t index, u32 address, std::string name) override;
|
||||
void UpdateWatchAddress(std::size_t index, u32 address) override;
|
||||
void UpdateWatchName(std::size_t index, const std::string& name) override;
|
||||
void UpdateWatchName(std::size_t index, std::string name) override;
|
||||
void EnableWatch(std::size_t index) override;
|
||||
void DisableWatch(std::size_t index) override;
|
||||
bool HasEnabledWatch(u32 address) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user