]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: replace variables for type bit sizes with constants
authorMartin Möhrmann <martisch@uos.de>
Thu, 10 Mar 2016 15:11:35 +0000 (16:11 +0100)
committerRob Pike <r@golang.org>
Wed, 16 Mar 2016 01:38:54 +0000 (01:38 +0000)
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 <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/fmt/print.go
src/fmt/scan.go

index b7d24a8c4732c501bc82eba931c642f44934acca..460712cfe98aaceda397f62b90978dcd53f05036 100644 (file)
@@ -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 "<nil>". The likeliest causes are a
index bf7c9acb8eccbf7161b32b5ca75544d0afc38784..08b0bf96a6e522dbd08cb5089ee76a463963dd6b 100644 (file)
@@ -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{}) {