mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-01-31 10:30:52 +00:00
Optimize IsHex() string helper function
This looks like a silly optimization, but this function gets called for transaction processing, so returning early when there's no point in even starting to iterate through a string is just smart coding.
This commit is contained in:
parent
763848c56e
commit
5d2a1b2557
@ -58,12 +58,16 @@ signed char HexDigit(char c)
|
||||
|
||||
bool IsHex(const string& str)
|
||||
{
|
||||
if ((str.size() <= 0) || (str.size()%2 != 0))
|
||||
return false;
|
||||
|
||||
for(std::string::const_iterator it(str.begin()); it != str.end(); ++it)
|
||||
{
|
||||
if (HexDigit(*it) < 0)
|
||||
return false;
|
||||
}
|
||||
return (str.size() > 0) && (str.size()%2 == 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
vector<unsigned char> ParseHex(const char* psz)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user