Skip to content
Permalink
Browse files

UICommon/NetPlayIndex: Take std::vector by const reference in ParseRe…

…sponse()

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.
  • Loading branch information...
lioncash committed Aug 4, 2019
1 parent 75f3656 commit 8285a94d93370a95c42cb8164928e578964ed6cd
Showing with 4 additions and 3 deletions.
  1. +4 −3 Source/Core/UICommon/NetPlayIndex.cpp
@@ -25,13 +25,14 @@ NetPlayIndex::~NetPlayIndex()
Remove();
}

static std::optional<picojson::value> ParseResponse(std::vector<u8> response)
static std::optional<picojson::value> ParseResponse(const std::vector<u8>& response)
{
std::string response_string(reinterpret_cast<char*>(response.data()), response.size());
const std::string response_string(reinterpret_cast<const char*>(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 {};

0 comments on commit 8285a94

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