mirror of
https://github.com/golang/go
synced 2024-11-23 18:50:05 -07:00
debug/pe: use bytes.IndexByte instead of a loop
Follow CL 98759 Change-Id: I58c8b769741b395e5bf4e723505b149d063d492a Reviewed-on: https://go-review.googlesource.com/99095 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
0657235660
commit
aa00d97447
@ -5,6 +5,7 @@
|
||||
package pe
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -13,8 +14,9 @@ import (
|
||||
// cstring converts ASCII byte sequence b to string.
|
||||
// It stops once it finds 0 or reaches end of b.
|
||||
func cstring(b []byte) string {
|
||||
var i int
|
||||
for i = 0; i < len(b) && b[i] != 0; i++ {
|
||||
i := bytes.IndexByte(b, 0)
|
||||
if i == -1 {
|
||||
i = len(b)
|
||||
}
|
||||
return string(b[:i])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user