Skip to content

Commit aa00d97

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 0657235 commit aa00d97

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/debug/pe/string.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package pe
66

77
import (
8+
"bytes"
89
"encoding/binary"
910
"fmt"
1011
"io"
@@ -13,8 +14,9 @@ import (
1314
// cstring converts ASCII byte sequence b to string.
1415
// It stops once it finds 0 or reaches end of b.
1516
func cstring(b []byte) string {
16-
var i int
17-
for i = 0; i < len(b) && b[i] != 0; i++ {
17+
i := bytes.IndexByte(b, 0)
18+
if i == -1 {
19+
i = len(b)
1820
}
1921
return string(b[:i])
2022
}

0 commit comments

Comments
 (0)