From: Matthew Dempsky Date: Fri, 9 Sep 2016 18:28:07 +0000 (-0700) Subject: cmd/compile/internal/syntax: remove strbyteseql X-Git-Tag: go1.8beta1~1413 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cfc0d6d8847eb959da2b6bd1c0fe1c0c7a19873e;p=gostls13.git cmd/compile/internal/syntax: remove strbyteseql cmd/compile already optimizes "string(b) == s" to avoid allocating a temporary string. Change-Id: I4244fbeae8d350261494135c357f9a6e2ab7ace3 Reviewed-on: https://go-review.googlesource.com/28931 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/compile/internal/syntax/scanner.go b/src/cmd/compile/internal/syntax/scanner.go index e78950ad1a..b84fcc5fd1 100644 --- a/src/cmd/compile/internal/syntax/scanner.go +++ b/src/cmd/compile/internal/syntax/scanner.go @@ -317,7 +317,7 @@ func (s *scanner) ident() { // possibly a keyword if len(lit) >= 2 { - if tok := keywordMap[hash(lit)]; tok != 0 && strbyteseql(tokstrings[tok], lit) { + if tok := keywordMap[hash(lit)]; tok != 0 && tokstrings[tok] == string(lit) { s.nlsemi = contains(1<<_Break|1<<_Continue|1<<_Fallthrough|1<<_Return, tok) s.tok = tok return @@ -347,18 +347,6 @@ func hash(s []byte) uint { return (uint(s[0])<<4 ^ uint(s[1]) + uint(len(s))) & uint(len(keywordMap)-1) } -func strbyteseql(s string, b []byte) bool { - if len(s) == len(b) { - for i, b := range b { - if s[i] != b { - return false - } - } - return true - } - return false -} - var keywordMap [1 << 6]token // size must be power of two func init() {