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 dddToByte(s []byte) byte {
|
||||
_ = s[2]
|
||||
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
|
||||
}
|
||||
|
||||
func dddStringToByte(s string) byte {
|
||||
_ = s[2]
|
||||
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue