From: Martin Möhrmann Date: Thu, 10 Mar 2016 15:11:35 +0000 (+0100) Subject: fmt: replace variables for type bit sizes with constants X-Git-Tag: go1.7beta1~1308 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a9d0244c334c6d8ac99eb59710d49bb85c707b29;p=gostls13.git fmt: replace variables for type bit sizes with constants Use constants instead of dynamically computed values to determine the bit sizes of types similar to how strconv and other packages directly compute these sizes. Move these constants near the code that uses them. Change-Id: I78d113b7e697466097e32653975df5990380c2c1 Reviewed-on: https://go-review.googlesource.com/20514 Run-TryBot: Rob Pike TryBot-Result: Gobot Gobot Reviewed-by: Rob Pike --- diff --git a/src/fmt/print.go b/src/fmt/print.go index b7d24a8c47..460712cfe9 100644 --- a/src/fmt/print.go +++ b/src/fmt/print.go @@ -578,11 +578,6 @@ func (p *pp) fmtPointer(value reflect.Value, verb rune) { } } -var ( - intBits = reflect.TypeOf(0).Bits() - uintptrBits = reflect.TypeOf(uintptr(0)).Bits() -) - func (p *pp) catchPanic(arg interface{}, verb rune) { if err := recover(); err != nil { // If it's a nil pointer, just say "". The likeliest causes are a diff --git a/src/fmt/scan.go b/src/fmt/scan.go index bf7c9acb8e..08b0bf96a6 100644 --- a/src/fmt/scan.go +++ b/src/fmt/scan.go @@ -915,9 +915,14 @@ func (s *ss) hexString() string { return string(s.buf) } -const floatVerbs = "beEfFgGv" +const ( + floatVerbs = "beEfFgGv" + + hugeWid = 1 << 30 -const hugeWid = 1 << 30 + intBits = 32 << (^uint(0) >> 63) + uintptrBits = 32 << (^uintptr(0) >> 63) +) // scanOne scans a single value, deriving the scanner from the type of the argument. func (s *ss) scanOne(verb rune, arg interface{}) {