mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
Make IsHex use string_view
This commit is contained in:
parent
c1d165a8c2
commit
40062997f2
2 changed files with 4 additions and 6 deletions
|
@ -58,12 +58,10 @@ signed char HexDigit(char c)
|
|||
return p_util_hexdigit[(unsigned char)c];
|
||||
}
|
||||
|
||||
bool IsHex(const std::string& str)
|
||||
bool IsHex(std::string_view str)
|
||||
{
|
||||
for(std::string::const_iterator it(str.begin()); it != str.end(); ++it)
|
||||
{
|
||||
if (HexDigit(*it) < 0)
|
||||
return false;
|
||||
for (char c : str) {
|
||||
if (HexDigit(c) < 0) return false;
|
||||
}
|
||||
return (str.size() > 0) && (str.size()%2 == 0);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ std::vector<unsigned char> ParseHex(std::string_view str);
|
|||
signed char HexDigit(char c);
|
||||
/* Returns true if each character in str is a hex character, and has an even
|
||||
* number of hex digits.*/
|
||||
bool IsHex(const std::string& str);
|
||||
bool IsHex(std::string_view str);
|
||||
/**
|
||||
* Return true if the string is a hex number, optionally prefixed with "0x"
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue