]> Cypherpunks repositories - gostls13.git/commit
fmt: change padding functions to avoid package init
authorMartin Möhrmann <martisch@uos.de>
Sat, 20 Feb 2016 00:51:32 +0000 (01:51 +0100)
committerRob Pike <r@golang.org>
Sat, 27 Feb 2016 06:59:39 +0000 (06:59 +0000)
commitabcad1e59de42e6275c735ba4303cbe1eb3adac7
treee5088f8427abbdefb308edcee9db1dfc236949cd
parent8b96bc6818ca673b4d6b832190f7e823c80804ca
fmt: change padding functions to avoid package init

Move the decision if zero padding is allowed to doPrintf
where the other formatting decisions are made.

Removes some dead code for negative f.wid that was never used
due to f.wid always being positive and f.minus deciding if left
or right padding should be used.

New padding code writes directly into the buffer and is as fast
as the old version but avoids the cost of needing package init.

name              old time/op  new time/op  delta
SprintfPadding-2   246ns ± 5%   245ns ± 4%   ~     (p=0.345 n=50+47)

Change-Id: I7dfddbac8e328f4ef0cdee8fafc0d06c784b2711
Reviewed-on: https://go-review.googlesource.com/19957
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
src/fmt/print.go