mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -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:
parent
72e07dbee0
commit
d60e51e353
@ -1483,10 +1483,7 @@ func ImportDir(dir string, mode ImportMode) (*Package, error) {
|
||||
}
|
||||
|
||||
var (
|
||||
bSlashSlash = []byte(slashSlash)
|
||||
bStarSlash = []byte(starSlash)
|
||||
bSlashStar = []byte(slashStar)
|
||||
bPlusBuild = []byte("+build")
|
||||
plusBuild = []byte("+build")
|
||||
|
||||
goBuildComment = []byte("//go:build")
|
||||
|
||||
@ -1555,7 +1552,7 @@ func (ctxt *Context) shouldBuild(content []byte, allTags map[string]bool) (shoul
|
||||
p = p[len(p):]
|
||||
}
|
||||
line = bytes.TrimSpace(line)
|
||||
if !bytes.HasPrefix(line, bSlashSlash) || !bytes.Contains(line, bPlusBuild) {
|
||||
if !bytes.HasPrefix(line, slashSlash) || !bytes.Contains(line, plusBuild) {
|
||||
continue
|
||||
}
|
||||
text := string(line)
|
||||
@ -1624,12 +1621,12 @@ Lines:
|
||||
}
|
||||
continue Lines
|
||||
}
|
||||
if bytes.HasPrefix(line, bSlashSlash) {
|
||||
if bytes.HasPrefix(line, slashSlash) {
|
||||
continue Lines
|
||||
}
|
||||
if bytes.HasPrefix(line, bSlashStar) {
|
||||
if bytes.HasPrefix(line, slashStar) {
|
||||
inSlashStar = true
|
||||
line = bytes.TrimSpace(line[len(bSlashStar):])
|
||||
line = bytes.TrimSpace(line[len(slashStar):])
|
||||
continue Comments
|
||||
}
|
||||
// Found non-comment text.
|
||||
|
Loading…
Reference in New Issue
Block a user