mirror of
https://github.com/golang/go
synced 2024-11-18 15:34:53 -07:00
stringer: don't emit unnecessary variables
Fixes golang/go#23014 Change-Id: I159f83bae0ed632b0b3c00f8ab02f5701acbc4cc Reviewed-on: https://go-review.googlesource.com/82215 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
04447353bc
commit
71657689f0
@ -110,7 +110,6 @@ const (
|
||||
var (
|
||||
_Gap_index_0 = [...]uint8{0, 3, 8}
|
||||
_Gap_index_1 = [...]uint8{0, 4, 7, 12, 17, 21}
|
||||
_Gap_index_2 = [...]uint8{0, 6}
|
||||
)
|
||||
|
||||
func (i Gap) String() string {
|
||||
|
@ -487,7 +487,9 @@ func (g *Generator) declareIndexAndNameVars(runs [][]Value, typeName string) {
|
||||
var indexes, names []string
|
||||
for i, run := range runs {
|
||||
index, name := g.createIndexAndNameDecl(run, typeName, fmt.Sprintf("_%d", i))
|
||||
if len(run) != 1 {
|
||||
indexes = append(indexes, index)
|
||||
}
|
||||
names = append(names, name)
|
||||
}
|
||||
g.Printf("const (\n")
|
||||
@ -495,12 +497,15 @@ func (g *Generator) declareIndexAndNameVars(runs [][]Value, typeName string) {
|
||||
g.Printf("\t%s\n", name)
|
||||
}
|
||||
g.Printf(")\n\n")
|
||||
|
||||
if len(indexes) > 0 {
|
||||
g.Printf("var (")
|
||||
for _, index := range indexes {
|
||||
g.Printf("\t%s\n", index)
|
||||
}
|
||||
g.Printf(")\n\n")
|
||||
}
|
||||
}
|
||||
|
||||
// declareIndexAndNameVar is the single-run version of declareIndexAndNameVars
|
||||
func (g *Generator) declareIndexAndNameVar(run []Value, typeName string) {
|
||||
|
Loading…
Reference in New Issue
Block a user