File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -66,17 +66,14 @@ bool IsHex(std::string_view str)
66
66
return (str.size () > 0 ) && (str.size ()%2 == 0 );
67
67
}
68
68
69
- bool IsHexNumber (const std::string& str)
69
+ bool IsHexNumber (std::string_view str)
70
70
{
71
- size_t starting_location = 0 ;
72
- if (str.size () > 2 && *str.begin () == ' 0' && *(str.begin ()+1 ) == ' x' ) {
73
- starting_location = 2 ;
74
- }
75
- for (const char c : str.substr (starting_location)) {
71
+ if (str.substr (0 , 2 ) == " 0x" ) str.remove_prefix (2 );
72
+ for (char c : str) {
76
73
if (HexDigit (c) < 0 ) return false ;
77
74
}
78
75
// Return false for empty string or "0x".
79
- return ( str.size () > starting_location) ;
76
+ return str.size () > 0 ;
80
77
}
81
78
82
79
std::vector<unsigned char > ParseHex (std::string_view str)
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ bool IsHex(std::string_view str);
63
63
/* *
64
64
* Return true if the string is a hex number, optionally prefixed with "0x"
65
65
*/
66
- bool IsHexNumber (const std::string& str);
66
+ bool IsHexNumber (std::string_view str);
67
67
std::vector<unsigned char > DecodeBase64 (const char * p, bool * pf_invalid = nullptr );
68
68
std::string DecodeBase64 (const std::string& str, bool * pf_invalid = nullptr );
69
69
std::string EncodeBase64 (Span<const unsigned char > input);
You can’t perform that action at this time.
0 commit comments