Commit d6d33f67 authored by Shahar Kohanim's avatar Shahar Kohanim Committed by David Crawshaw

cmd/link: use encbuf when writing integers

name       old s/op   new s/op   delta
LinkCmdGo  0.59 ± 6%  0.58 ± 5%  -1.61%  (p=0.000 n=99+99)

GOGC=off:
name       old s/op   new s/op   delta
LinkCmdGo  0.50 ± 3%  0.49 ± 3%  -1.28%  (p=0.000 n=98+99)

Change-Id: I737ae056214999441a210c69ec0cf4febc39a715
Reviewed-on: https://go-review.googlesource.com/20914Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 78fc59ef
...@@ -286,15 +286,13 @@ func Asmplan9sym() { ...@@ -286,15 +286,13 @@ func Asmplan9sym() {
var symt *LSym var symt *LSym
func Wputl(w uint16) { func Wputb(w uint16) { Cwrite(Append16b(encbuf[:0], w)) }
Cput(uint8(w)) func Lputb(l uint32) { Cwrite(Append32b(encbuf[:0], l)) }
Cput(uint8(w >> 8)) func Vputb(v uint64) { Cwrite(Append64b(encbuf[:0], v)) }
}
func Wputb(w uint16) { func Wputl(w uint16) { Cwrite(Append16l(encbuf[:0], w)) }
Cput(uint8(w >> 8)) func Lputl(l uint32) { Cwrite(Append32l(encbuf[:0], l)) }
Cput(uint8(w)) func Vputl(v uint64) { Cwrite(Append64l(encbuf[:0], v)) }
}
func Append16b(b []byte, v uint16) []byte { func Append16b(b []byte, v uint16) []byte {
return append(b, uint8(v>>8), uint8(v)) return append(b, uint8(v>>8), uint8(v))
...@@ -303,20 +301,6 @@ func Append16l(b []byte, v uint16) []byte { ...@@ -303,20 +301,6 @@ func Append16l(b []byte, v uint16) []byte {
return append(b, uint8(v), uint8(v>>8)) return append(b, uint8(v), uint8(v>>8))
} }
func Lputb(l uint32) {
Cput(uint8(l >> 24))
Cput(uint8(l >> 16))
Cput(uint8(l >> 8))
Cput(uint8(l))
}
func Lputl(l uint32) {
Cput(uint8(l))
Cput(uint8(l >> 8))
Cput(uint8(l >> 16))
Cput(uint8(l >> 24))
}
func Append32b(b []byte, v uint32) []byte { func Append32b(b []byte, v uint32) []byte {
return append(b, uint8(v>>24), uint8(v>>16), uint8(v>>8), uint8(v)) return append(b, uint8(v>>24), uint8(v>>16), uint8(v>>8), uint8(v))
} }
...@@ -324,26 +308,14 @@ func Append32l(b []byte, v uint32) []byte { ...@@ -324,26 +308,14 @@ func Append32l(b []byte, v uint32) []byte {
return append(b, uint8(v), uint8(v>>8), uint8(v>>16), uint8(v>>24)) return append(b, uint8(v), uint8(v>>8), uint8(v>>16), uint8(v>>24))
} }
func Vputb(v uint64) {
Lputb(uint32(v >> 32))
Lputb(uint32(v))
}
func Vputl(v uint64) {
Lputl(uint32(v))
Lputl(uint32(v >> 32))
}
func Append64b(b []byte, v uint64) []byte { func Append64b(b []byte, v uint64) []byte {
b = Append32b(b, uint32(v>>32)) return append(b, uint8(v>>56), uint8(v>>48), uint8(v>>40), uint8(v>>32),
b = Append32b(b, uint32(v)) uint8(v>>24), uint8(v>>16), uint8(v>>8), uint8(v))
return b
} }
func Append64l(b []byte, v uint64) []byte { func Append64l(b []byte, v uint64) []byte {
b = Append32l(b, uint32(v)) return append(b, uint8(v), uint8(v>>8), uint8(v>>16), uint8(v>>24),
b = Append32l(b, uint32(v>>32)) uint8(v>>32), uint8(v>>40), uint8(v>>48), uint8(v>>56))
return b
} }
type byPkg []*Library type byPkg []*Library
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment