Skip to content

Commit 7e1028a

Browse files
cuonglmmvdan
authored andcommitted
cmd/compile: avoid range over copy of array
Passes toostash-check. Slightly reduce compiler binary size: file before after Δ % compile 21087288 21070776 -16512 -0.078% total 131847020 131830508 -16512 -0.013% file before after Δ % cmd/compile/internal/gc.a 9007472 8999640 -7832 -0.087% total 127117794 127109962 -7832 -0.006% Change-Id: I4aadd68d0a7545770598bed9d3a4d05899b67b52 Reviewed-on: https://go-review.googlesource.com/c/go/+/205777 Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 1d90e1a commit 7e1028a

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

src/cmd/compile/internal/gc/escape.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ func (e *Escape) finish(fns []*Node) {
13711371
fn.Esc = EscFuncTagged
13721372

13731373
narg := 0
1374-
for _, fs := range types.RecvsParams {
1374+
for _, fs := range &types.RecvsParams {
13751375
for _, f := range fs(fn.Type).Fields().Slice() {
13761376
narg++
13771377
f.Note = e.paramTag(fn, narg, f)

src/cmd/compile/internal/gc/iexport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ func (w *exportWriter) funcExt(n *Node) {
954954
w.symIdx(n.Sym)
955955

956956
// Escape analysis.
957-
for _, fs := range types.RecvsParams {
957+
for _, fs := range &types.RecvsParams {
958958
for _, f := range fs(n.Type).FieldSlice() {
959959
w.string(f.Note)
960960
}

src/cmd/compile/internal/gc/iimport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ func (r *importReader) funcExt(n *Node) {
660660
r.symIdx(n.Sym)
661661

662662
// Escape analysis.
663-
for _, fs := range types.RecvsParams {
663+
for _, fs := range &types.RecvsParams {
664664
for _, f := range fs(n.Type).FieldSlice() {
665665
f.Note = r.string()
666666
}

src/cmd/compile/internal/gc/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ func loadsys() {
10711071
typecheckok = true
10721072

10731073
typs := runtimeTypes()
1074-
for _, d := range runtimeDecls {
1074+
for _, d := range &runtimeDecls {
10751075
sym := Runtimepkg.Lookup(d.name)
10761076
typ := typs[d.typ]
10771077
switch d.tag {
@@ -1374,7 +1374,7 @@ var concurrentFlagOK = [256]bool{
13741374
}
13751375

13761376
func concurrentBackendAllowed() bool {
1377-
for i, x := range Debug {
1377+
for i, x := range &Debug {
13781378
if x != 0 && !concurrentFlagOK[i] {
13791379
return false
13801380
}

src/cmd/compile/internal/gc/noder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ func (p *noder) expr(expr syntax.Expr) *Node {
646646
}
647647
n := p.nod(expr, op, p.expr(expr.X), nil)
648648
var index [3]*Node
649-
for i, x := range expr.Index {
649+
for i, x := range &expr.Index {
650650
if x != nil {
651651
index[i] = p.expr(x)
652652
}

src/cmd/compile/internal/gc/plive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ func (lv *Liveness) regEffects(v *ssa.Value) (uevar, kill liveRegMask) {
419419
if v.Type.Etype != types.TTUPLE {
420420
v.Fatalf("location pair %s has non-tuple type %v", loc, v.Type)
421421
}
422-
for i, loc1 := range loc {
422+
for i, loc1 := range &loc {
423423
if loc1 == nil {
424424
continue
425425
}

src/cmd/compile/internal/gc/ssa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3216,7 +3216,7 @@ func init() {
32163216
var p4 []*sys.Arch
32173217
var p8 []*sys.Arch
32183218
var lwatomics []*sys.Arch
3219-
for _, a := range sys.Archs {
3219+
for _, a := range &sys.Archs {
32203220
all = append(all, a)
32213221
if a.PtrSize == 4 {
32223222
p4 = append(p4, a)

src/cmd/compile/internal/gc/universe.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var builtinFuncs = [...]struct {
6666
// isBuiltinFuncName reports whether name matches a builtin function
6767
// name.
6868
func isBuiltinFuncName(name string) bool {
69-
for _, fn := range builtinFuncs {
69+
for _, fn := range &builtinFuncs {
7070
if fn.name == name {
7171
return true
7272
}
@@ -92,7 +92,7 @@ func initUniverse() {
9292

9393
// lexinit initializes known symbols and the basic types.
9494
func lexinit() {
95-
for _, s := range basicTypes {
95+
for _, s := range &basicTypes {
9696
etype := s.etype
9797
if int(etype) >= len(types.Types) {
9898
Fatalf("lexinit: %s bad etype", s.name)
@@ -111,13 +111,13 @@ func lexinit() {
111111
asNode(s2.Def).Name = new(Name)
112112
}
113113

114-
for _, s := range builtinFuncs {
114+
for _, s := range &builtinFuncs {
115115
s2 := builtinpkg.Lookup(s.name)
116116
s2.Def = asTypesNode(newname(s2))
117117
asNode(s2.Def).SetSubOp(s.op)
118118
}
119119

120-
for _, s := range unsafeFuncs {
120+
for _, s := range &unsafeFuncs {
121121
s2 := unsafepkg.Lookup(s.name)
122122
s2.Def = asTypesNode(newname(s2))
123123
asNode(s2.Def).SetSubOp(s.op)
@@ -402,7 +402,7 @@ func lexinit1() {
402402
dowidth(types.Runetype)
403403

404404
// backend-dependent builtin types (e.g. int).
405-
for _, s := range typedefs {
405+
for _, s := range &typedefs {
406406
s1 := builtinpkg.Lookup(s.name)
407407

408408
sameas := s.sameas32

0 commit comments

Comments
 (0)