From: Martin Möhrmann Date: Sat, 12 Nov 2016 19:08:02 +0000 (+0100) Subject: time: simplify stringification of Month X-Git-Tag: go1.8beta1~176 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=524cd4855e11a26d07a7ca7ee45d3bee38c54425;p=gostls13.git time: simplify stringification of Month Simplifies https://golang.org/cl/33145 which fixed #17720. Change-Id: Ib922d493cdc5920832dc95b55094796baca7243e Reviewed-on: https://go-review.googlesource.com/33194 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/time/time.go b/src/time/time.go index 00fafb64dd..10b32461e1 100644 --- a/src/time/time.go +++ b/src/time/time.go @@ -118,13 +118,9 @@ func (m Month) String() string { if January <= m && m <= December { return months[m-1] } - const prefix = "%!Month(" - buf := make([]byte, 20+len(prefix)+1) - buf[len(buf)-1] = ')' - n := fmtInt(buf[:len(buf)-1], uint64(m)) - n -= len(prefix) - copy(buf[n:], prefix) - return string(buf[n:]) + buf := make([]byte, 20) + n := fmtInt(buf, uint64(m)) + return "%!Month(" + string(buf[n:]) + ")" } // A Weekday specifies a day of the week (Sunday = 0, ...).