]> Cypherpunks repositories - gostls13.git/commitdiff
time: use bytealg.IndexByte in byteString
authorTobias Klauser <tklauser@distanz.ch>
Tue, 20 Feb 2024 16:10:16 +0000 (17:10 +0100)
committerGopher Robot <gobot@golang.org>
Mon, 26 Feb 2024 20:46:01 +0000 (20:46 +0000)
Change-Id: I0d42bca7c6ee63c05a0ca09c165f2f591edf7c34
Reviewed-on: https://go-review.googlesource.com/c/go/+/565356
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

src/time/zoneinfo_read.go

index 707dd1189d03d7b26b3a849e0fd128ea90533ef5..9ce735d279ca0ecf0e37e68ba9e52654ec66cbb1 100644 (file)
@@ -11,6 +11,7 @@ package time
 
 import (
        "errors"
+       "internal/bytealg"
        "runtime"
        "syscall"
 )
@@ -99,10 +100,8 @@ func (d *dataIO) rest() []byte {
 
 // Make a string by stopping at the first NUL
 func byteString(p []byte) string {
-       for i := 0; i < len(p); i++ {
-               if p[i] == 0 {
-                       return string(p[0:i])
-               }
+       if i := bytealg.IndexByte(p, 0); i != -1 {
+               p = p[:i]
        }
        return string(p)
 }