1
0
mirror of https://github.com/golang/go synced 2024-11-05 14:36:11 -07:00

go/build: remove unnecessary copies of package variables

These variables never change, we don't need second copies of them.

Also rename bPlusBuild to plusBuild, since it is the only remaining
variable with a "b" prefix.

Change-Id: I97089b001d23e9b0f2096e19d9ceed7a9bbb377d
Reviewed-on: https://go-review.googlesource.com/c/go/+/429636
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Ian Lance Taylor 2022-09-08 17:17:55 -07:00 committed by Gopher Robot
parent 72e07dbee0
commit d60e51e353

View File

@ -1483,10 +1483,7 @@ func ImportDir(dir string, mode ImportMode) (*Package, error) {
} }
var ( var (
bSlashSlash = []byte(slashSlash) plusBuild = []byte("+build")
bStarSlash = []byte(starSlash)
bSlashStar = []byte(slashStar)
bPlusBuild = []byte("+build")
goBuildComment = []byte("//go:build") goBuildComment = []byte("//go:build")
@ -1555,7 +1552,7 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool) (shoul
p = p[len(p):] p = p[len(p):]
} }
line = bytes.TrimSpace(line) line = bytes.TrimSpace(line)
if !bytes.HasPrefix(line, bSlashSlash) || !bytes.Contains(line, bPlusBuild) { if !bytes.HasPrefix(line, slashSlash) || !bytes.Contains(line, plusBuild) {
continue continue
} }
text := string(line) text := string(line)
@ -1624,12 +1621,12 @@ Lines:
} }
continue Lines continue Lines
} }
if bytes.HasPrefix(line, bSlashSlash) { if bytes.HasPrefix(line, slashSlash) {
continue Lines continue Lines
} }
if bytes.HasPrefix(line, bSlashStar) { if bytes.HasPrefix(line, slashStar) {
inSlashStar = true inSlashStar = true
line = bytes.TrimSpace(line[len(bSlashStar):]) line = bytes.TrimSpace(line[len(slashStar):])
continue Comments continue Comments
} }
// Found non-comment text. // Found non-comment text.