mirror of https://github.com/golang/go.git
archive/tar: preallocate slice from paxHeaders
Preallocate keys slice with the length of paxHeaders map to prevent slice growth with append operations. Change-Id: Ic9a927c4eaa775690a4ef912d61dd06f38e11510 Reviewed-on: https://go-review.googlesource.com/23782 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
2cb471e40d
commit
77e68ea78a
|
|
@ -317,7 +317,7 @@ func (tw *Writer) writePAXHeader(hdr *Header, paxHeaders map[string]string) erro
|
|||
var buf bytes.Buffer
|
||||
|
||||
// Keys are sorted before writing to body to allow deterministic output.
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(paxHeaders))
|
||||
for k := range paxHeaders {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue