Skip to content
Browse files

UICommon/NetPlayIndex: Use a std::string_view for EncryptID()/Decrypt…


These parameters only acted as views into the provided strings, so these
can just be turned into non-owning string views.
  • Loading branch information...
lioncash committed Aug 4, 2019
1 parent 2830fe8 commit 75f3656804eb76113fe2e7750f1d03743a039ba6
Showing with 5 additions and 4 deletions.
  1. +2 −2 Source/Core/UICommon/NetPlayIndex.cpp
  2. +3 −2 Source/Core/UICommon/NetPlayIndex.h
@@ -256,7 +256,7 @@ std::vector<std::pair<std::string, std::string>> NetPlayIndex::GetRegions()
// It isn't very secure but is preferable to adding another dependency on mbedtls
// The encrypted data is encoded as nibbles with the character 'A' as the base offset

bool NetPlaySession::EncryptID(const std::string& password)
bool NetPlaySession::EncryptID(std::string_view password)
if (password.empty())
return false;
@@ -284,7 +284,7 @@ bool NetPlaySession::EncryptID(const std::string& password)
return true;

std::optional<std::string> NetPlaySession::DecryptID(const std::string& password) const
std::optional<std::string> NetPlaySession::DecryptID(std::string_view password) const
if (password.empty())
return {};
@@ -8,6 +8,7 @@
#include <map>
#include <optional>
#include <string>
#include <string_view>
#include <thread>
#include <utility>
#include <vector>
@@ -29,8 +30,8 @@ struct NetPlaySession
bool has_password;
bool in_game;

bool EncryptID(const std::string& password);
std::optional<std::string> DecryptID(const std::string& password) const;
bool EncryptID(std::string_view password);
std::optional<std::string> DecryptID(std::string_view password) const;

class NetPlayIndex

0 comments on commit 75f3656

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