From 141b09726dcfc1fa9f04ee9e08e6fa4af00fa57b Mon Sep 17 00:00:00 2001 From: smasher164 Date: Tue, 20 Aug 2019 23:11:22 -0400 Subject: net/http: make copyValues append instead of calling Add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This results in a performance boost: name old time/op new time/op delta CopyValues-4 3.46µs ± 3% 1.53µs ± 3% -55.85% (p=0.000 n=18+19) name old alloc/op new alloc/op delta CopyValues-4 1.52kB ± 0% 0.74kB ± 0% -51.58% (p=0.000 n=20+20) name old allocs/op new allocs/op delta CopyValues-4 24.0 ± 0% 11.0 ± 0% -54.17% (p=0.000 n=20+20) Fixes #33744. Change-Id: Ibc653fb076a9a6aaa775fcc9ca720fb90e68cf96 Reviewed-on: https://go-review.googlesource.com/c/go/+/191057 Run-TryBot: Emmanuel Odeke TryBot-Result: Gobot Gobot Reviewed-by: Emmanuel Odeke --- src/net/http/request.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/net/http/request.go') diff --git a/src/net/http/request.go b/src/net/http/request.go index 6e113f1607..0b195a89a6 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -1165,9 +1165,7 @@ func (l *maxBytesReader) Close() error { func copyValues(dst, src url.Values) { for k, vs := range src { - for _, value := range vs { - dst.Add(k, value) - } + dst[k] = append(dst[k], vs...) } } -- cgit v1.3