diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-07-28 22:46:08 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-07-28 23:00:58 -0400 |
| commit | c212310fbe0b205b62c4d3ac997060cf4fc26e2f (patch) | |
| tree | f202206200baa1f4b0a3486b6a6148168d7df877 /Source/Core/VideoCommon/OnScreenDisplay.cpp | |
| parent | 50b240fcbd3822e3d7aa9d5fa2c86274393de14a (diff) | |
VideoCommon/OnScreenDisplay: Take Message's std::string parameter by value
Allows callers to std::move strings into the functions (or automatically
assume the move constructor/move assignment operator for rvalue
references, potentially avoiding copies altogether.
Diffstat (limited to 'Source/Core/VideoCommon/OnScreenDisplay.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/OnScreenDisplay.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp index 24d8987d99..b52de17cbf 100644 --- a/Source/Core/VideoCommon/OnScreenDisplay.cpp +++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp @@ -27,8 +27,8 @@ constexpr float WINDOW_PADDING = 4.0f; // Pixels between subsequent OSD message struct Message { Message() = default; - Message(const std::string& text_, u32 timestamp_, u32 color_) - : text(text_), timestamp(timestamp_), color(color_) + Message(std::string text_, u32 timestamp_, u32 color_) + : text(std::move(text_)), timestamp(timestamp_), color(color_) { } std::string text; @@ -79,18 +79,18 @@ static float DrawMessage(int index, const Message& msg, const ImVec2& position, return window_height; } -void AddTypedMessage(MessageType type, const std::string& message, u32 ms, u32 rgba) +void AddTypedMessage(MessageType type, std::string message, u32 ms, u32 rgba) { std::lock_guard<std::mutex> lock(s_messages_mutex); s_messages.erase(type); - s_messages.emplace(type, Message(message, Common::Timer::GetTimeMs() + ms, rgba)); + s_messages.emplace(type, Message(std::move(message), Common::Timer::GetTimeMs() + ms, rgba)); } -void AddMessage(const std::string& message, u32 ms, u32 rgba) +void AddMessage(std::string message, u32 ms, u32 rgba) { std::lock_guard<std::mutex> lock(s_messages_mutex); s_messages.emplace(MessageType::Typeless, - Message(message, Common::Timer::GetTimeMs() + ms, rgba)); + Message(std::move(message), Common::Timer::GetTimeMs() + ms, rgba)); } void DrawMessages() |
