]> Cypherpunks repositories - gostls13.git/commitdiff
time: use internal/itoa
authorTobias Klauser <tklauser@distanz.ch>
Wed, 24 Aug 2022 12:25:11 +0000 (14:25 +0200)
committerGopher Robot <gobot@golang.org>
Mon, 29 Aug 2022 20:05:34 +0000 (20:05 +0000)
In initLocal for GOOS=js, use internal/itoa introduced in CL 301549
instead of a local implementation.

Change-Id: If107d5cf0ce56f4d926507db2cbd6da422c6d15a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425302
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/time/zoneinfo_js.go

index 06306cfd54d160f0fc7fc1b0aa08ea54fdf5e82e..8da34a21fbae0a6f7d4b78fd9857150d05ada91f 100644 (file)
@@ -7,6 +7,7 @@
 package time
 
 import (
+       "internal/itoa"
        "syscall/js"
 )
 
@@ -35,31 +36,10 @@ func initLocal() {
        } else {
                z.name += "+"
        }
-       z.name += itoa(offset / 60)
+       z.name += itoa.Itoa(offset / 60)
        min := offset % 60
        if min != 0 {
-               z.name += ":" + itoa(min)
+               z.name += ":" + itoa.Itoa(min)
        }
        localLoc.zone = []zone{z}
 }
-
-// itoa is like strconv.Itoa but only works for values of i in range [0,99].
-// It panics if i is out of range.
-func itoa(i int) string {
-       if i < 10 {
-               return digits[i : i+1]
-       }
-       return smallsString[i*2 : i*2+2]
-}
-
-const smallsString = "00010203040506070809" +
-       "10111213141516171819" +
-       "20212223242526272829" +
-       "30313233343536373839" +
-       "40414243444546474849" +
-       "50515253545556575859" +
-       "60616263646566676869" +
-       "70717273747576777879" +
-       "80818283848586878889" +
-       "90919293949596979899"
-const digits = "0123456789"