Update bytes.go

This commit is contained in:
Alvarez 2025-10-31 13:20:44 +01:00 committed by GitHub
parent da548126ba
commit 72f3bfd838
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,7 +27,7 @@ import (
// FromHex returns the bytes represented by the hexadecimal string s.
// s may be prefixed with "0x".
func FromHex(s string) []byte {
if has0xPrefix(s) {
if hexutil.Has0xPrefix(s) {
s = s[2:]
}
if len(s)%2 == 1 {
@ -47,11 +47,6 @@ func CopyBytes(b []byte) (copiedBytes []byte) {
return
}
// has0xPrefix validates str begins with '0x' or '0X'.
func has0xPrefix(str string) bool {
return len(str) >= 2 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')
}
// isHexCharacter returns bool of c being a valid hexadecimal.
func isHexCharacter(c byte) bool {
return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')