From 08223bad9f46f6c23bac915ae8d41eb7eac71b64 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 29 May 2019 06:09:47 -0400 Subject: VideoCommon/NetPlayChatUI: Set member variable within the constructor initializer list Member variables should be initialized within the constructor initializer list if possible. --- Source/Core/VideoCommon/NetPlayChatUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/NetPlayChatUI.cpp') diff --git a/Source/Core/VideoCommon/NetPlayChatUI.cpp b/Source/Core/VideoCommon/NetPlayChatUI.cpp index 7587229ee0..29becc020f 100644 --- a/Source/Core/VideoCommon/NetPlayChatUI.cpp +++ b/Source/Core/VideoCommon/NetPlayChatUI.cpp @@ -14,8 +14,8 @@ constexpr size_t MAX_BACKLOG_SIZE = 100; std::unique_ptr g_netplay_chat_ui; NetPlayChatUI::NetPlayChatUI(std::function callback) + : m_message_callback{std::move(callback)} { - m_message_callback = std::move(callback); } void NetPlayChatUI::Display() -- cgit v1.2.3 From 50a15b7484af90441f556bb0febd87b41818c5b6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 29 May 2019 06:12:27 -0400 Subject: 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. --- Source/Core/VideoCommon/NetPlayChatUI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/NetPlayChatUI.cpp') diff --git a/Source/Core/VideoCommon/NetPlayChatUI.cpp b/Source/Core/VideoCommon/NetPlayChatUI.cpp index 29becc020f..6c8bce9227 100644 --- a/Source/Core/VideoCommon/NetPlayChatUI.cpp +++ b/Source/Core/VideoCommon/NetPlayChatUI.cpp @@ -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) -- cgit v1.2.3 From 53b115b81e626d563afb62939ac192f56974817b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 29 May 2019 06:14:40 -0400 Subject: VideoCommon/NetPlayChatUI: Use nullptr where applicable We gotsa type dedicated to this concept already :P --- Source/Core/VideoCommon/NetPlayChatUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/NetPlayChatUI.cpp') diff --git a/Source/Core/VideoCommon/NetPlayChatUI.cpp b/Source/Core/VideoCommon/NetPlayChatUI.cpp index 6c8bce9227..7428233286 100644 --- a/Source/Core/VideoCommon/NetPlayChatUI.cpp +++ b/Source/Core/VideoCommon/NetPlayChatUI.cpp @@ -106,7 +106,7 @@ void NetPlayChatUI::SendMessage() void NetPlayChatUI::Activate() { if (ImGui::IsItemFocused()) - ImGui::SetWindowFocus(NULL); + ImGui::SetWindowFocus(nullptr); else m_activate = true; } -- cgit v1.2.3 From c958fc1278f90b8fb4e401abc9a7a16f76f42401 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 29 May 2019 06:18:55 -0400 Subject: VideoCommon/NetPlayChatUI: Default destructor in the cpp file Ensures that the destruction logic is kept local to the translation unit (making it nicer when it comes to forward declaring non-trivial types). It also doesn't really do much to define it in the header. --- Source/Core/VideoCommon/NetPlayChatUI.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Source/Core/VideoCommon/NetPlayChatUI.cpp') diff --git a/Source/Core/VideoCommon/NetPlayChatUI.cpp b/Source/Core/VideoCommon/NetPlayChatUI.cpp index 7428233286..a84c26d8d7 100644 --- a/Source/Core/VideoCommon/NetPlayChatUI.cpp +++ b/Source/Core/VideoCommon/NetPlayChatUI.cpp @@ -18,6 +18,8 @@ NetPlayChatUI::NetPlayChatUI(std::function callback) { } +NetPlayChatUI::~NetPlayChatUI() = default; + void NetPlayChatUI::Display() { const float scale = ImGui::GetIO().DisplayFramebufferScale.x; -- cgit v1.2.3