Commit cfc0d6d8 authored by Matthew Dempsky's avatar Matthew Dempsky

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 <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 3877f820
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment