Skip to content

Commit 4006299

Browse files
sipaMacroFake
authored andcommitted
Make IsHex use string_view
1 parent c1d165a commit 4006299

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/util/strencodings.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,10 @@ signed char HexDigit(char c)
5858
return p_util_hexdigit[(unsigned char)c];
5959
}
6060

61-
bool IsHex(const std::string& str)
61+
bool IsHex(std::string_view str)
6262
{
63-
for(std::string::const_iterator it(str.begin()); it != str.end(); ++it)
64-
{
65-
if (HexDigit(*it) < 0)
66-
return false;
63+
for (char c : str) {
64+
if (HexDigit(c) < 0) return false;
6765
}
6866
return (str.size() > 0) && (str.size()%2 == 0);
6967
}

src/util/strencodings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ std::vector<unsigned char> ParseHex(std::string_view str);
5959
signed char HexDigit(char c);
6060
/* Returns true if each character in str is a hex character, and has an even
6161
* number of hex digits.*/
62-
bool IsHex(const std::string& str);
62+
bool IsHex(std::string_view str);
6363
/**
6464
* Return true if the string is a hex number, optionally prefixed with "0x"
6565
*/

0 commit comments

Comments
 (0)