aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2018-03-07 09:46:47 +0100
committerTobias Klauser <tobias.klauser@gmail.com>2018-03-07 16:12:08 +0000
commitaa00d9744785f5215ec8e47a9bb00a4289cea3d2 (patch)
treed2dd09d5bad8643c50d2ebe2b653157888aaf9bf /src/debug
parent06572356602c414b84019693cec7286882aa845e (diff)
downloadgo-aa00d9744785f5215ec8e47a9bb00a4289cea3d2.tar.xz
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>
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/pe/string.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/debug/pe/string.go b/src/debug/pe/string.go
index c30255f341..cab0366ade 100644
--- a/src/debug/pe/string.go
+++ b/src/debug/pe/string.go
@@ -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])
}