diff options
| author | Ian Lance Taylor <iant@golang.org> | 2022-09-08 17:17:55 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-14 14:52:52 +0000 |
| commit | d60e51e3539986fcca331cc27f4730a4fe266149 (patch) | |
| tree | 1c3632c1e6a35d9b1c3865f812845408fd8fc219 /src | |
| parent | 72e07dbee086659833ef560ecce517a183d95b23 (diff) | |
| download | go-d60e51e3539986fcca331cc27f4730a4fe266149.tar.xz | |
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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/go/build/build.go | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/go/build/build.go b/src/go/build/build.go index b914b67d1d..4bc34086b3 100644 --- a/src/go/build/build.go +++ b/src/go/build/build.go @@ -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. |
