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 (
|
var (
|
||||||
_Gap_index_0 = [...]uint8{0, 3, 8}
|
_Gap_index_0 = [...]uint8{0, 3, 8}
|
||||||
_Gap_index_1 = [...]uint8{0, 4, 7, 12, 17, 21}
|
_Gap_index_1 = [...]uint8{0, 4, 7, 12, 17, 21}
|
||||||
_Gap_index_2 = [...]uint8{0, 6}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (i Gap) String() string {
|
func (i Gap) String() string {
|
||||||
|
|
|
@ -487,7 +487,9 @@ func (g *Generator) declareIndexAndNameVars(runs [][]Value, typeName string) {
|
||||||
var indexes, names []string
|
var indexes, names []string
|
||||||
for i, run := range runs {
|
for i, run := range runs {
|
||||||
index, name := g.createIndexAndNameDecl(run, typeName, fmt.Sprintf("_%d", i))
|
index, name := g.createIndexAndNameDecl(run, typeName, fmt.Sprintf("_%d", i))
|
||||||
indexes = append(indexes, index)
|
if len(run) != 1 {
|
||||||
|
indexes = append(indexes, index)
|
||||||
|
}
|
||||||
names = append(names, name)
|
names = append(names, name)
|
||||||
}
|
}
|
||||||
g.Printf("const (\n")
|
g.Printf("const (\n")
|
||||||
|
@ -495,11 +497,14 @@ func (g *Generator) declareIndexAndNameVars(runs [][]Value, typeName string) {
|
||||||
g.Printf("\t%s\n", name)
|
g.Printf("\t%s\n", name)
|
||||||
}
|
}
|
||||||
g.Printf(")\n\n")
|
g.Printf(")\n\n")
|
||||||
g.Printf("var (")
|
|
||||||
for _, index := range indexes {
|
if len(indexes) > 0 {
|
||||||
g.Printf("\t%s\n", index)
|
g.Printf("var (")
|
||||||
|
for _, index := range indexes {
|
||||||
|
g.Printf("\t%s\n", index)
|
||||||
|
}
|
||||||
|
g.Printf(")\n\n")
|
||||||
}
|
}
|
||||||
g.Printf(")\n\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// declareIndexAndNameVar is the single-run version of declareIndexAndNameVars
|
// declareIndexAndNameVar is the single-run version of declareIndexAndNameVars
|
||||||
|
|
Loading…
Reference in New Issue