mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-02 23:27:31 -04: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
|
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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user