mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #12159: Use the character based overload for std::string::find.
a73aab7
Use the character based overload for std::string::find. (Alin Rus)
Pull request description:
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.
Tree-SHA512: dc7684b1551e6d779eb989e9a74363f9b978059a7c0f3db09d01744c7e6452961f9e671173265e71efff27afbcb80c0fe2c11b6dff2290e54a49193fa25a5679
This commit is contained in:
parent
8462ae91aa
commit
2f8888a86e
@ -286,7 +286,7 @@ static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& str
|
|||||||
bool bScriptHash = false;
|
bool bScriptHash = false;
|
||||||
if (vStrInputParts.size() == 3) {
|
if (vStrInputParts.size() == 3) {
|
||||||
std::string flags = vStrInputParts[2];
|
std::string flags = vStrInputParts[2];
|
||||||
bScriptHash = (flags.find("S") != std::string::npos);
|
bScriptHash = (flags.find('S') != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bScriptHash) {
|
if (bScriptHash) {
|
||||||
@ -339,7 +339,7 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
|
|||||||
bool bScriptHash = false;
|
bool bScriptHash = false;
|
||||||
if (vStrInputParts.size() == numkeys + 4) {
|
if (vStrInputParts.size() == numkeys + 4) {
|
||||||
std::string flags = vStrInputParts.back();
|
std::string flags = vStrInputParts.back();
|
||||||
bScriptHash = (flags.find("S") != std::string::npos);
|
bScriptHash = (flags.find('S') != std::string::npos);
|
||||||
}
|
}
|
||||||
else if (vStrInputParts.size() > numkeys + 4) {
|
else if (vStrInputParts.size() > numkeys + 4) {
|
||||||
// Validate that there were no more parameters passed
|
// Validate that there were no more parameters passed
|
||||||
@ -408,7 +408,7 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str
|
|||||||
bool bScriptHash = false;
|
bool bScriptHash = false;
|
||||||
if (vStrInputParts.size() == 3) {
|
if (vStrInputParts.size() == 3) {
|
||||||
std::string flags = vStrInputParts.back();
|
std::string flags = vStrInputParts.back();
|
||||||
bScriptHash = (flags.find("S") != std::string::npos);
|
bScriptHash = (flags.find('S') != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scriptPubKey.size() > MAX_SCRIPT_SIZE) {
|
if (scriptPubKey.size() > MAX_SCRIPT_SIZE) {
|
||||||
|
@ -85,11 +85,11 @@ static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const Uni
|
|||||||
//entries from config file.
|
//entries from config file.
|
||||||
static bool multiUserAuthorized(std::string strUserPass)
|
static bool multiUserAuthorized(std::string strUserPass)
|
||||||
{
|
{
|
||||||
if (strUserPass.find(":") == std::string::npos) {
|
if (strUserPass.find(':') == std::string::npos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string strUser = strUserPass.substr(0, strUserPass.find(":"));
|
std::string strUser = strUserPass.substr(0, strUserPass.find(':'));
|
||||||
std::string strPass = strUserPass.substr(strUserPass.find(":") + 1);
|
std::string strPass = strUserPass.substr(strUserPass.find(':') + 1);
|
||||||
|
|
||||||
for (const std::string& strRPCAuth : gArgs.GetArgs("-rpcauth")) {
|
for (const std::string& strRPCAuth : gArgs.GetArgs("-rpcauth")) {
|
||||||
//Search for multi-user login/pass "rpcauth" from config
|
//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);
|
boost::trim(strUserPass64);
|
||||||
std::string strUserPass = DecodeBase64(strUserPass64);
|
std::string strUserPass = DecodeBase64(strUserPass64);
|
||||||
|
|
||||||
if (strUserPass.find(":") != std::string::npos)
|
if (strUserPass.find(':') != std::string::npos)
|
||||||
strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(":"));
|
strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(':'));
|
||||||
|
|
||||||
//Check if authorized under single-user field
|
//Check if authorized under single-user field
|
||||||
if (TimingResistantEqual(strUserPass, strRPCUserColonPass)) {
|
if (TimingResistantEqual(strUserPass, strRPCUserColonPass)) {
|
||||||
|
@ -423,8 +423,8 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
|||||||
{
|
{
|
||||||
uint256 txid;
|
uint256 txid;
|
||||||
int32_t nOutput;
|
int32_t nOutput;
|
||||||
std::string strTxid = uriParts[i].substr(0, uriParts[i].find("-"));
|
std::string strTxid = uriParts[i].substr(0, uriParts[i].find('-'));
|
||||||
std::string strOutput = uriParts[i].substr(uriParts[i].find("-")+1);
|
std::string strOutput = uriParts[i].substr(uriParts[i].find('-')+1);
|
||||||
|
|
||||||
if (!ParseInt32(strOutput, &nOutput) || !IsHex(strTxid))
|
if (!ParseInt32(strOutput, &nOutput) || !IsHex(strTxid))
|
||||||
return RESTERR(req, HTTP_BAD_REQUEST, "Parse error");
|
return RESTERR(req, HTTP_BAD_REQUEST, "Parse error");
|
||||||
|
@ -253,7 +253,7 @@ UniValue RPCConvertNamedValues(const std::string &strMethod, const std::vector<s
|
|||||||
UniValue params(UniValue::VOBJ);
|
UniValue params(UniValue::VOBJ);
|
||||||
|
|
||||||
for (const std::string &s: strParams) {
|
for (const std::string &s: strParams) {
|
||||||
size_t pos = s.find("=");
|
size_t pos = s.find('=');
|
||||||
if (pos == std::string::npos) {
|
if (pos == std::string::npos) {
|
||||||
throw(std::runtime_error("No '=' in named argument '"+s+"', this needs to be present for every argument (even if it is empty)"));
|
throw(std::runtime_error("No '=' in named argument '"+s+"', this needs to be present for every argument (even if it is empty)"));
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ UniValue setban(const JSONRPCRequest& request)
|
|||||||
CNetAddr netAddr;
|
CNetAddr netAddr;
|
||||||
bool isSubnet = false;
|
bool isSubnet = false;
|
||||||
|
|
||||||
if (request.params[0].get_str().find("/") != std::string::npos)
|
if (request.params[0].get_str().find('/') != std::string::npos)
|
||||||
isSubnet = true;
|
isSubnet = true;
|
||||||
|
|
||||||
if (!isSubnet) {
|
if (!isSubnet) {
|
||||||
|
Loading…
Reference in New Issue
Block a user