From d60e51e3539986fcca331cc27f4730a4fe266149 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 8 Sep 2022 17:17:55 -0700 Subject: [PATCH] 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 Reviewed-by: Dmitri Shuralyov Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Benny Siegert Reviewed-by: Dmitri Shuralyov Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor --- src/go/build/build.go | 13 +++++-------- 1 file 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. -- 2.50.0