diff --git a/Source/Core/Core/DSP/LabelMap.cpp b/Source/Core/Core/DSP/LabelMap.cpp index dd045c5a44..5ff74b2e58 100644 --- a/Source/Core/Core/DSP/LabelMap.cpp +++ b/Source/Core/Core/DSP/LabelMap.cpp @@ -14,8 +14,8 @@ namespace DSP { struct LabelMap::Label { - Label(const std::string& lbl, s32 address, LabelType ltype) - : name(lbl), addr(address), type(ltype) + Label(std::string lbl, s32 address, LabelType ltype) + : name(std::move(lbl)), addr(address), type(ltype) { } std::string name; @@ -42,7 +42,7 @@ void LabelMap::RegisterDefaults() } } -void LabelMap::RegisterLabel(const std::string& label, u16 lval, LabelType type) +void LabelMap::RegisterLabel(std::string label, u16 lval, LabelType type) { const std::optional old_value = GetLabelValue(label); if (old_value && old_value != lval) @@ -51,10 +51,10 @@ void LabelMap::RegisterLabel(const std::string& label, u16 lval, LabelType type) *old_value); DeleteLabel(label); } - labels.emplace_back(label, lval, type); + labels.emplace_back(std::move(label), lval, type); } -void LabelMap::DeleteLabel(const std::string& label) +void LabelMap::DeleteLabel(std::string_view label) { const auto iter = std::find_if(labels.cbegin(), labels.cend(), [&label](const auto& entry) { return entry.name == label; }); diff --git a/Source/Core/Core/DSP/LabelMap.h b/Source/Core/Core/DSP/LabelMap.h index e9bcd3950b..2061a7ba55 100644 --- a/Source/Core/Core/DSP/LabelMap.h +++ b/Source/Core/Core/DSP/LabelMap.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "Common/CommonTypes.h" @@ -27,8 +28,8 @@ public: ~LabelMap(); void RegisterDefaults(); - void RegisterLabel(const std::string& label, u16 lval, LabelType type = LABEL_VALUE); - void DeleteLabel(const std::string& label); + void RegisterLabel(std::string label, u16 lval, LabelType type = LABEL_VALUE); + void DeleteLabel(std::string_view label); std::optional GetLabelValue(const std::string& label, LabelType type = LABEL_ANY) const; void Clear();