Commit 77e68ea7 authored by Gyu-Ho Lee's avatar Gyu-Ho Lee Committed by Joe Tsai

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/23782Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 2cb471e4
......@@ -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)
}
......
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