plan9: use bytes.IndexByte instead of a for loop

Change-Id: Iae896dc32e775cb469fc3d0d367fd7c7825161ec
Reviewed-on: https://go-review.googlesource.com/99516
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Tobias Klauser
2018-03-08 15:20:46 +00:00
committed by Tobias Klauser
parent e64a828a1b
commit 7dca6fe1f4
+5 -5
View File
@@ -12,6 +12,7 @@
package plan9 package plan9
import ( import (
"bytes"
"syscall" "syscall"
"unsafe" "unsafe"
) )
@@ -50,12 +51,11 @@ func atoi(b []byte) (n uint) {
} }
func cstring(s []byte) string { func cstring(s []byte) string {
for i := range s { i := bytes.IndexByte(s, 0)
if s[i] == 0 { if i == -1 {
return string(s[0:i]) i = len(s)
}
} }
return string(s) return string(s[:i])
} }
func errstr() string { func errstr() string {