• Brad Fitzpatrick's avatar
    net/textproto: reduce allocations in ReadMIMEHeader · 16c3f82e
    Brad Fitzpatrick authored
    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
    16c3f82e
reader.go 16.1 KB