]> Cypherpunks repositories - gostls13.git/commit
time: unify formatting of decimals for timestamps
authorMartin Möhrmann <martisch@uos.de>
Sun, 11 Jan 2015 10:29:00 +0000 (11:29 +0100)
committerRobert Griesemer <gri@golang.org>
Wed, 8 Apr 2015 16:17:22 +0000 (16:17 +0000)
commitd5ef69814204f1bf8bee75bc89efcbcb33a64606
tree265673bfa976af076b59f9a8865dfcfc6891a66d
parent5c22a4a2e13a7f43d1f3b887e17bd50cf8713afe
time: unify formatting of decimals for timestamps

Change function appendUint to appendInt with variable-width 0-padding.

This allows the decimal for the year to be generated without extra code
to handle the wider padding and directly handles negative numbers.

Removes the special casing for numbers with one and two digits.
The special case for 0 was unreachable.

The new version is slightly slower.

benchmark              old ns/op     new ns/op     delta
BenchmarkFormat        444           454           +2.25%
BenchmarkFormatNow     398           415           +4.27%

Change-Id: I4ddef96bf07ad35dca76053321d510441ec6d4f5
Reviewed-on: https://go-review.googlesource.com/2751
Reviewed-by: Robert Griesemer <gri@golang.org>
src/time/format.go