From: Kir Kolyshkin Date: Fri, 7 Nov 2025 19:07:16 +0000 (-0800) Subject: cmd/go/internal/modindex: eliminate duplicated vars X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=31a03fe20c5361924622fd4cc92edcd08ba07072;p=gostls13.git cmd/go/internal/modindex: eliminate duplicated vars There is no need to have two sets of the same slices. The names are chosen to be the same as in ../imports. Change-Id: I92dca46127e25b5226cce3cc11749cd5957ad609 Reviewed-on: https://go-review.googlesource.com/c/go/+/718800 Reviewed-by: Sean Liao LUCI-TryBot-Result: Go LUCI Auto-Submit: Sean Liao Reviewed-by: Keith Randall Reviewed-by: Junyang Shao --- diff --git a/src/cmd/go/internal/modindex/build.go b/src/cmd/go/internal/modindex/build.go index 053e04dfe5..c0acb8ff58 100644 --- a/src/cmd/go/internal/modindex/build.go +++ b/src/cmd/go/internal/modindex/build.go @@ -182,9 +182,10 @@ func fileListForExt(p *build.Package, ext string) *[]string { } var ( - slashSlash = []byte("//") - slashStar = []byte("/*") - starSlash = []byte("*/") + bSlashSlash = []byte("//") + bSlashStar = []byte("/*") + bStarSlash = []byte("*/") + bPlusBuild = []byte("+build") ) var dummyPkg build.Package @@ -296,11 +297,6 @@ func cleanDecls(m map[string][]token.Position) ([]string, map[string][]token.Pos } var ( - bSlashSlash = slashSlash - bStarSlash = starSlash - bSlashStar = slashStar - bPlusBuild = []byte("+build") - goBuildComment = []byte("//go:build") errMultipleGoBuild = errors.New("multiple //go:build comments") @@ -382,7 +378,7 @@ Lines: end = len(content) - len(p) continue Lines } - if !bytes.HasPrefix(line, slashSlash) { // Not comment line + if !bytes.HasPrefix(line, bSlashSlash) { // Not comment line ended = true } @@ -399,9 +395,9 @@ Lines: Comments: for len(line) > 0 { if inSlashStar { - if i := bytes.Index(line, starSlash); i >= 0 { + if i := bytes.Index(line, bStarSlash); i >= 0 { inSlashStar = false - line = bytes.TrimSpace(line[i+len(starSlash):]) + line = bytes.TrimSpace(line[i+len(bStarSlash):]) continue Comments } continue Lines