]> Cypherpunks repositories - gostls13.git/commit
net/http: use a struct instead of a string in transport conn cache key
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 30 Jan 2014 08:57:04 +0000 (09:57 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 30 Jan 2014 08:57:04 +0000 (09:57 +0100)
commitae8251b0aa946177877f61b45a96e90319dce1ff
tree3752f72ee7726e6c40f2f1071d1097994454508a
parent7a73f32725ff8b13a4cca703972fa76e598f4436
net/http: use a struct instead of a string in transport conn cache key

The Transport's idle connection cache is keyed by a string,
for pre-Go 1.0 reasons.  Ever since Go has been able to use
structs as map keys, there's been a TODO in the code to use
structs instead of allocating strings. This change does that.

Saves 3 allocatins and ~100 bytes of garbage per client
request. But because string hashing is so fast these days
(thanks, Keith), the performance is a wash: what we gain
on GC and not allocating, we lose in slower hashing. (hashing
structs of strings is slower than 1 string)

This seems a bit faster usually, but I've also seen it be a
bit slower. But at least it's how I've wanted it now, and it
the allocation improvements are consistent.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/58260043
src/pkg/net/http/export_test.go
src/pkg/net/http/proxy_test.go
src/pkg/net/http/transport.go