mirror of
https://github.com/miekg/dns.git
synced 2025-10-18 05:11:01 +02:00
Hoist bounds check in dddToByte
This eliminates two of the bounds checks in dddToByte and dddStringToByte.
This commit is contained in:
parent
2eeda8aabc
commit
ab9dd29c1d
2
msg.go
2
msg.go
@ -528,10 +528,12 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) {
|
|||||||
func isDigit(b byte) bool { return b >= '0' && b <= '9' }
|
func isDigit(b byte) bool { return b >= '0' && b <= '9' }
|
||||||
|
|
||||||
func dddToByte(s []byte) byte {
|
func dddToByte(s []byte) byte {
|
||||||
|
_ = s[2]
|
||||||
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
|
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
|
||||||
}
|
}
|
||||||
|
|
||||||
func dddStringToByte(s string) byte {
|
func dddStringToByte(s string) byte {
|
||||||
|
_ = s[2]
|
||||||
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
|
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user