]> Cypherpunks repositories - gostls13.git/commit
cmd/gofmt: normalize number prefixes and exponents
authorRobert Griesemer <gri@golang.org>
Wed, 30 Jan 2019 06:12:13 +0000 (22:12 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 11 Feb 2019 23:25:08 +0000 (23:25 +0000)
commit69de40c9af9253cc738f4c4ac2a7be37bff5be94
tree6e79cce4a7d94a1dc30a4dd8d19b01c073a5f4dc
parent257f30433b66c0ec992fe36ccd5403580a7cbced
cmd/gofmt: normalize number prefixes and exponents

Rewrite non-decimal number prefixes to always use a lower-case base
("0X" -> "0x", etc.), and rewrite exponents to use a lower-case 'e'
or 'p'. Leave hexadecimal digits and 0-octals alone.

Comparing the best time of 3 runs of `time go test -run All` with
the time for a gofmt that doesn't do the rewrite shows no increase
in runtime for this bulk gofmt application (in fact on my machine
I see a small decline, probably due to cache effects).

R=Go1.13

Updates #12711.
Updates #19308.
Updates #29008.

Change-Id: I9c6ebed2ffa0a6a001c59412a73382090955f5a9
Reviewed-on: https://go-review.googlesource.com/c/160184
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/gofmt/gofmt.go
src/cmd/gofmt/testdata/go2numbers.golden
src/cmd/gofmt/testdata/go2numbers.input