mirror of
https://github.com/golang/go
synced 2024-11-18 07:14:44 -07:00
net/http/httputil: preallocate trailerKeys slice
To prevent slice growths with append operations. Change-Id: Icdb745b23cc44dfaf3e16746b94c06997f814e15 Reviewed-on: https://go-review.googlesource.com/23784 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
4383e4387b
commit
5bbb854cee
@ -221,7 +221,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
// The "Trailer" header isn't included in the Transport's response,
|
||||
// at least for *http.Transport. Build it up from Trailer.
|
||||
if len(res.Trailer) > 0 {
|
||||
var trailerKeys []string
|
||||
trailerKeys := make([]string, 0, len(res.Trailer))
|
||||
for k := range res.Trailer {
|
||||
trailerKeys = append(trailerKeys, k)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user