Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: reduce allocations in (Header).clone #29915
What version of Go are you using (
CC @bradfitz for
Note that number of allocations doesn't necessarily correlate with overall throughput or latency. (Sometimes, collecting the allocation is less work for the program than avoiding it.)
In this case, the proposed change introduces a time/space tradeoff: if the user stores one particular slice, the may end up pinning the entire larger slice where before most of it could be collected.
(You'd want to support a change with benchmarks either way.)
Brilliant, thanks so much for putting together the PR!
I maybe would have done it eventually... but I've not contributed to Go before, and I just know from each experience that a first-time patch to a new project takes at least a few hours to learn the ropes and get set up with a new build & code review system, and just didn't have the time to spare.
I'm happy with the CL above, thank you!