Make IsHex use string_view

This commit is contained in:
Pieter Wuille
2022-04-04 11:12:04 -04:00
committed by MacroFake
parent c1d165a8c2
commit 40062997f2
2 changed files with 4 additions and 6 deletions

View File

@@ -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);
}