]> Cypherpunks repositories - gostls13.git/commit
fmt: unify array and slice formatting for bytes and other types
authorMartin Möhrmann <martisch@uos.de>
Tue, 15 Mar 2016 16:14:03 +0000 (17:14 +0100)
committerRob Pike <r@golang.org>
Sun, 27 Mar 2016 21:34:20 +0000 (21:34 +0000)
commit9149aa10cc2f7d3061303754ab45c55eff42ac89
treee20a2100068067a393f44b142caeb4400c692f56
parenta637717e7da8a28f0c3dd55ba52d94aab28fa1bb
fmt: unify array and slice formatting for bytes and other types

Make verbs b,c,o and U work for any array and slice of integer
type including byte and uint8.

Fix a bug that triggers badverb for []uint8 and []byte type
on the slice/array level instead of on each element like for
any other slice or array type.

Add tests that make sure we do not accidentally alter the
behavior of printing []byte for []byte and []uint8 type
if they are used at the top level when formatting with %#v.

name               old time/op  new time/op  delta
SprintfHexBytes-2   177ns ± 2%   176ns ± 2%   ~     (p=0.066 n=48+49)
SprintfBytes-2      330ns ± 1%   329ns ± 1%   ~     (p=0.118 n=45+47)

Fixes #13478

Change-Id: I99328a184973ae219bcc0f69c3978cb1ff462888
Reviewed-on: https://go-review.googlesource.com/20686
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/fmt/fmt_test.go
src/fmt/print.go