From 8285a94d93370a95c42cb8164928e578964ed6cd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 12:36:49 -0400 Subject: [PATCH] UICommon/NetPlayIndex: Take std::vector by const reference in ParseResponse() This variable isn't std::moved anywhere and is just read out of into a string. Instead of making a copy, and then another copy of the data into a std::string, we can take it by reference, only copying the data once. --- Source/Core/UICommon/NetPlayIndex.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/UICommon/NetPlayIndex.cpp b/Source/Core/UICommon/NetPlayIndex.cpp index 734a739971..476a43eabc 100644 --- a/Source/Core/UICommon/NetPlayIndex.cpp +++ b/Source/Core/UICommon/NetPlayIndex.cpp @@ -25,13 +25,14 @@ NetPlayIndex::~NetPlayIndex() Remove(); } -static std::optional ParseResponse(std::vector response) +static std::optional ParseResponse(const std::vector& response) { - std::string response_string(reinterpret_cast(response.data()), response.size()); + const std::string response_string(reinterpret_cast(response.data()), + response.size()); picojson::value json; - auto error = picojson::parse(json, response_string); + const auto error = picojson::parse(json, response_string); if (!error.empty()) return {};