]> Cypherpunks repositories - gostls13.git/commit
net/textproto: reduce allocations in ReadMIMEHeader
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 3 Jul 2013 05:37:19 +0000 (22:37 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 3 Jul 2013 05:37:19 +0000 (22:37 -0700)
commit16c3f82ed45931775565b8945bcdcd88183dedb6
tree312f139698f0c729bb589051054c6b0e73fcb9ce
parentb4d4ff9381ab9a58a1c45610793f30cef6f646de
net/textproto: reduce allocations in ReadMIMEHeader

ReadMIMEHeader is used by net/http, net/mail, and
mime/multipart.

Don't do so many small allocations. Calculate up front
how much we'll probably need.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader         8433         7467  -11.45%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           23           14  -39.13%

benchmark                  old bytes    new bytes    delta
BenchmarkReadMIMEHeader         1705         1343  -21.23%

R=golang-dev, r, iant, adg
CC=golang-dev
https://golang.org/cl/8179043
src/pkg/net/textproto/reader.go