]> Cypherpunks repositories - gostls13.git/commit
mime: Remove an allocation in word decoding.
authorJustin Nuß <nuss.justin@gmail.com>
Wed, 9 Sep 2015 19:10:43 +0000 (21:10 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 18 Oct 2015 17:31:52 +0000 (17:31 +0000)
commitd0c9b40964f1951d2684545f1a6df64be899d26d
tree7bc8c71f5a37a4d5816df0948f47a4549f1d8df1
parentdb2e73faeb97f39653180080b0cc4c05501cbf94
mime: Remove an allocation in word decoding.

This fixes a TODO in (*WordDecoder).Decode by replacing a call to strings.Split with
simple prefix/suffix checking and some custom slicing.

Benchmark results:

benchmark                    old ns/op     new ns/op     delta
BenchmarkQEncodeWord-8       740           693           -6.35%
BenchmarkQDecodeWord-8       1291          727           -43.69%
BenchmarkQDecodeHeader-8     1194          767           -35.76%

benchmark                    old allocs     new allocs     delta
BenchmarkQEncodeWord-8       1              1              +0.00%
BenchmarkQDecodeWord-8       3              2              -33.33%
BenchmarkQDecodeHeader-8     3              2              -33.33%

benchmark                    old bytes     new bytes     delta
BenchmarkQEncodeWord-8       48            48            +0.00%
BenchmarkQDecodeWord-8       128           48            -62.50%
BenchmarkQDecodeHeader-8     128           48            -62.50%

Change-Id: I2d6844c75ec2e2b79be2e49b7fc4ca320b7e84e5
Reviewed-on: https://go-review.googlesource.com/14432
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/mime/encodedword.go