From 75f3656804eb76113fe2e7750f1d03743a039ba6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 12:32:29 -0400 Subject: [PATCH] UICommon/NetPlayIndex: Use a std::string_view for EncryptID()/DecryptID() These parameters only acted as views into the provided strings, so these can just be turned into non-owning string views. --- Source/Core/UICommon/NetPlayIndex.cpp | 4 ++-- Source/Core/UICommon/NetPlayIndex.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Core/UICommon/NetPlayIndex.cpp b/Source/Core/UICommon/NetPlayIndex.cpp index c528c8f5e2..734a739971 100644 --- a/Source/Core/UICommon/NetPlayIndex.cpp +++ b/Source/Core/UICommon/NetPlayIndex.cpp @@ -256,7 +256,7 @@ std::vector> 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 NetPlaySession::DecryptID(const std::string& password) const +std::optional NetPlaySession::DecryptID(std::string_view password) const { if (password.empty()) return {}; diff --git a/Source/Core/UICommon/NetPlayIndex.h b/Source/Core/UICommon/NetPlayIndex.h index a94e7daf35..04f1d8b3b1 100644 --- a/Source/Core/UICommon/NetPlayIndex.h +++ b/Source/Core/UICommon/NetPlayIndex.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -29,8 +30,8 @@ struct NetPlaySession bool has_password; bool in_game; - bool EncryptID(const std::string& password); - std::optional DecryptID(const std::string& password) const; + bool EncryptID(std::string_view password); + std::optional DecryptID(std::string_view password) const; }; class NetPlayIndex