mirror of
https://github.com/golang/sys.git
synced 2026-01-29 15:12:09 +03:00
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:
committed by
Tobias Klauser
parent
e64a828a1b
commit
7dca6fe1f4
@@ -12,6 +12,7 @@
|
||||
package plan9
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -50,12 +51,11 @@ func atoi(b []byte) (n uint) {
|
||||
}
|
||||
|
||||
func cstring(s []byte) string {
|
||||
for i := range s {
|
||||
if s[i] == 0 {
|
||||
return string(s[0:i])
|
||||
}
|
||||
i := bytes.IndexByte(s, 0)
|
||||
if i == -1 {
|
||||
i = len(s)
|
||||
}
|
||||
return string(s)
|
||||
return string(s[:i])
|
||||
}
|
||||
|
||||
func errstr() string {
|
||||
|
||||
Reference in New Issue
Block a user