]> Cypherpunks repositories - gostls13.git/commit
net/textproto: faster header canonicalization with fewer allocations
authorJeff R. Allen <jra@nella.org>
Mon, 12 Nov 2012 23:31:42 +0000 (15:31 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 12 Nov 2012 23:31:42 +0000 (15:31 -0800)
commit7e7b89f7d0191537094d91963c9fe1647ef43635
treeae223bdb7d7d0ebeb13d318e1896df421a745199
parent73c67606e9659db662b195e241fdffb1d43a75e1
net/textproto: faster header canonicalization with fewer allocations

By keeping a single copy of the strings that commonly show up
in headers, we can avoid one string allocation per header.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader        19590        10824  -44.75%
BenchmarkUncommon               3168         1861  -41.26%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           32           25  -21.88%
BenchmarkUncommon                  5            5    0.00%

R=bradfitz, golang-dev, dave, rsc, jra
CC=golang-dev
https://golang.org/cl/6721055
src/pkg/net/textproto/reader.go
src/pkg/net/textproto/reader_test.go