]> Cypherpunks repositories - gostls13.git/commit
fmt: optimize %x and %X formatting for byte slices and strings
authorMartin Möhrmann <martisch@uos.de>
Sat, 27 Feb 2016 18:47:43 +0000 (19:47 +0100)
committerRob Pike <r@golang.org>
Thu, 3 Mar 2016 08:25:28 +0000 (08:25 +0000)
commit033e3e106e6132b530759bf97f7b359b9897ae25
treea528b270ada5720bd5d5c3629f291f996e65b069
parent71d13a8c01706c0196a843116d403fe8eb446130
fmt: optimize %x and %X formatting for byte slices and strings

No extra buffering is needed to save the encoding
since the left padding can be computed and written out
before the encoding is generated.

Add extra tests to both string and byte slice formatting.

name                old time/op  new time/op  delta
SprintfHexString-2   410ns ± 3%   194ns ± 3%  -52.60%  (p=0.000 n=20+19)
SprintfHexBytes-2    431ns ± 3%   202ns ± 2%  -53.13%  (p=0.000 n=18+20)

Change-Id: Ibca4316427c89f834e4faee61614493c7eedb42b
Reviewed-on: https://go-review.googlesource.com/20097
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/fmt/fmt_test.go
src/fmt/format.go