aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/scanner.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2016-09-09 11:28:07 -0700
committerMatthew Dempsky <mdempsky@google.com>2016-09-09 19:25:56 +0000
commitcfc0d6d8847eb959da2b6bd1c0fe1c0c7a19873e (patch)
treea72f633034c692f72214087acba09417e3af9d0f /src/cmd/compile/internal/syntax/scanner.go
parent3877f820a61886b74bb596bdb128a8d705a44628 (diff)
downloadgo-cfc0d6d8847eb959da2b6bd1c0fe1c0c7a19873e.tar.gz
go-cfc0d6d8847eb959da2b6bd1c0fe1c0c7a19873e.zip
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: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/syntax/scanner.go')
-rw-r--r--src/cmd/compile/internal/syntax/scanner.go14
1 files changed, 1 insertions, 13 deletions
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() {