From ab9dd29c1d39a209ad0d56876a3c26e6860a78bf Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Mon, 26 Nov 2018 11:52:43 +1030 Subject: [PATCH] Hoist bounds check in dddToByte This eliminates two of the bounds checks in dddToByte and dddStringToByte. --- msg.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/msg.go b/msg.go index b1367c1f..fcb1412c 100644 --- a/msg.go +++ b/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')) }