From 4760b33326392c459bb5825938d57ce55d40224a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 20 Feb 2024 17:10:16 +0100 Subject: [PATCH] time: use bytealg.IndexByte in byteString Change-Id: I0d42bca7c6ee63c05a0ca09c165f2f591edf7c34 Reviewed-on: https://go-review.googlesource.com/c/go/+/565356 Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Reviewed-by: Michael Pratt Auto-Submit: Tobias Klauser --- src/time/zoneinfo_read.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/time/zoneinfo_read.go b/src/time/zoneinfo_read.go index 707dd1189d..9ce735d279 100644 --- a/src/time/zoneinfo_read.go +++ b/src/time/zoneinfo_read.go @@ -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) } -- 2.48.1