mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: clean up various bits of code
* replace a copy of IsMethod with a call of it. * a few more switches where they simplify the code. * prefer composite literals over "n := new(...); n.x = y; ...". * use defers to get rid of three goto labels. * rewrite updateHasCall into two funcs to remove gotos. Passes toolstash-check on std cmd. Change-Id: Icb5442a89a87319ef4b640bbc5faebf41b193ef1 Reviewed-on: https://go-review.googlesource.com/72070 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
7092a312e5
commit
006bc57095
9 changed files with 53 additions and 79 deletions
|
|
@ -16,9 +16,7 @@ import (
|
|||
)
|
||||
|
||||
// architecture-independent object file output
|
||||
const (
|
||||
ArhdrSize = 60
|
||||
)
|
||||
const ArhdrSize = 60
|
||||
|
||||
func formathdr(arhdr []byte, name string, size int64) {
|
||||
copy(arhdr[:], fmt.Sprintf("%-16s%-12d%-6d%-6d%-8o%-10d`\n", name, 0, 0, 0, 0644, size))
|
||||
|
|
@ -62,6 +60,7 @@ func dumpobj1(outfile string, mode int) {
|
|||
fmt.Printf("can't create %s: %v\n", outfile, err)
|
||||
errorexit()
|
||||
}
|
||||
defer bout.Close()
|
||||
|
||||
startobj := int64(0)
|
||||
var arhdr [ArhdrSize]byte
|
||||
|
|
@ -108,7 +107,6 @@ func dumpobj1(outfile string, mode int) {
|
|||
}
|
||||
|
||||
if mode&modeLinkerObj == 0 {
|
||||
bout.Close()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -170,8 +168,6 @@ func dumpobj1(outfile string, mode int) {
|
|||
formathdr(arhdr[:], "_go_.o", size)
|
||||
bout.Write(arhdr[:])
|
||||
}
|
||||
|
||||
bout.Close()
|
||||
}
|
||||
|
||||
func addptabs() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue