]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modindex: eliminate duplicated vars
authorKir Kolyshkin <kolyshkin@gmail.com>
Fri, 7 Nov 2025 19:07:16 +0000 (11:07 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 12 Feb 2026 17:31:15 +0000 (09:31 -0800)
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 <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
src/cmd/go/internal/modindex/build.go

index 053e04dfe599e9bfcddb8cb368d77f3af9f8e114..c0acb8ff587d7f534250026142780329d3c4d17f 100644 (file)
@@ -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