mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.cc] cmd/5g etc: code cleanup: delay var decls and eliminate dead code
Ran rsc.io/grind rev 6f0e601 on the source files. The cleanups move var declarations as close to the use as possible, splitting disjoint uses of the var into separate variables. They also remove dead code (especially in func sudoaddable), which helps with the var moving. There's more cleanup to come, but this alone cuts the time spent compiling html/template on my 2013 MacBook Pro from 3.1 seconds to 2.3 seconds. Change-Id: I4de499f47b1dd47a560c310bbcde6b08d425cfd6 Reviewed-on: https://go-review.googlesource.com/5637 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
3af0d791be
commit
382b44eb7c
65 changed files with 4089 additions and 6822 deletions
|
|
@ -33,9 +33,7 @@ package obj
|
|||
// Code and data passes.
|
||||
|
||||
func Brchain(ctxt *Link, p *Prog) *Prog {
|
||||
var i int
|
||||
|
||||
for i = 0; i < 20; i++ {
|
||||
for i := 0; i < 20; i++ {
|
||||
if p == nil || p.As != AJMP || p.Pcond == nil {
|
||||
return p
|
||||
}
|
||||
|
|
@ -46,10 +44,9 @@ func Brchain(ctxt *Link, p *Prog) *Prog {
|
|||
}
|
||||
|
||||
func brloop(ctxt *Link, p *Prog) *Prog {
|
||||
var c int
|
||||
var q *Prog
|
||||
|
||||
c = 0
|
||||
c := 0
|
||||
for q = p; q != nil; q = q.Pcond {
|
||||
if q.As != AJMP || q.Pcond == nil {
|
||||
break
|
||||
|
|
@ -152,12 +149,11 @@ func checkaddr(ctxt *Link, p *Prog, a *Addr) {
|
|||
func linkpatch(ctxt *Link, sym *LSym) {
|
||||
var c int32
|
||||
var name string
|
||||
var p *Prog
|
||||
var q *Prog
|
||||
|
||||
ctxt.Cursym = sym
|
||||
|
||||
for p = sym.Text; p != nil; p = p.Link {
|
||||
for p := sym.Text; p != nil; p = p.Link {
|
||||
checkaddr(ctxt, p, &p.From)
|
||||
checkaddr(ctxt, p, &p.From3)
|
||||
checkaddr(ctxt, p, &p.To)
|
||||
|
|
@ -203,7 +199,7 @@ func linkpatch(ctxt *Link, sym *LSym) {
|
|||
p.Pcond = q
|
||||
}
|
||||
|
||||
for p = sym.Text; p != nil; p = p.Link {
|
||||
for p := sym.Text; p != nil; p = p.Link {
|
||||
p.Mark = 0 /* initialization for follow */
|
||||
if p.Pcond != nil {
|
||||
p.Pcond = brloop(ctxt, p.Pcond)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue