From a73aab7cd8343d795b1a7408bd71f522262ac76e Mon Sep 17 00:00:00 2001 From: Alin Rus Date: Thu, 11 Jan 2018 21:40:51 +0100 Subject: Use the character based overload for std::string::find. std::string::find has a character based overload as can be seen here (4th oveload): http://www.cplusplus.com/reference/string/string/find/ Use that instead of constantly allocating temporary strings. --- src/httprpc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/httprpc.cpp') diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 66f7a6a718..5e9e419744 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -85,11 +85,11 @@ static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const Uni //entries from config file. static bool multiUserAuthorized(std::string strUserPass) { - if (strUserPass.find(":") == std::string::npos) { + if (strUserPass.find(':') == std::string::npos) { return false; } - std::string strUser = strUserPass.substr(0, strUserPass.find(":")); - std::string strPass = strUserPass.substr(strUserPass.find(":") + 1); + std::string strUser = strUserPass.substr(0, strUserPass.find(':')); + std::string strPass = strUserPass.substr(strUserPass.find(':') + 1); for (const std::string& strRPCAuth : gArgs.GetArgs("-rpcauth")) { //Search for multi-user login/pass "rpcauth" from config @@ -132,8 +132,8 @@ static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUserna boost::trim(strUserPass64); std::string strUserPass = DecodeBase64(strUserPass64); - if (strUserPass.find(":") != std::string::npos) - strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(":")); + if (strUserPass.find(':') != std::string::npos) + strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(':')); //Check if authorized under single-user field if (TimingResistantEqual(strUserPass, strRPCUserColonPass)) { -- cgit v1.2.3