Skip to content
Permalink
Browse files

VideoCommon/NetPlayChatUI: Take std::string by value in AppendChat()

Given we're simply storing the std::string into a deque. We can emplace
it and move it. Completely avoiding copies with the current usage of the
function.
  • Loading branch information...
lioncash committed May 29, 2019
1 parent 08223ba commit 50a15b7484af90441f556bb0febd87b41818c5b6
Showing with 3 additions and 3 deletions.
  1. +2 −2 Source/Core/VideoCommon/NetPlayChatUI.cpp
  2. +1 −1 Source/Core/VideoCommon/NetPlayChatUI.h
@@ -78,12 +78,12 @@ void NetPlayChatUI::Display()
ImGui::End();
}

void NetPlayChatUI::AppendChat(const std::string& message, NetPlayChatUI::Color color)
void NetPlayChatUI::AppendChat(std::string message, Color color)
{
if (m_messages.size() > MAX_BACKLOG_SIZE)
m_messages.pop_front();

m_messages.push_back({message, color});
m_messages.emplace_back(std::move(message), color);

// Only scroll to bottom, if we were at the bottom previously
if (m_is_scrolled_to_bottom)
@@ -20,7 +20,7 @@ class NetPlayChatUI
using Color = std::array<float, 3>;

void Display();
void AppendChat(const std::string& message, Color color);
void AppendChat(std::string message, Color color);
void SendMessage();
void Activate();

0 comments on commit 50a15b7

Please sign in to comment.
You can’t perform that action at this time.