Hoist bounds check in dddToByte

This eliminates two of the bounds checks in dddToByte and
dddStringToByte.
This commit is contained in:
Tom Thorogood 2018-11-26 11:52:43 +10:30
parent 2eeda8aabc
commit ab9dd29c1d
No known key found for this signature in database
GPG Key ID: 86C63CDA416C6D2F
1 changed files with 2 additions and 0 deletions

2
msg.go
View File

@ -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'))
}