aboutsummaryrefslogtreecommitdiff
path: root/src/debug/macho
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2018-03-05 07:40:26 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2018-03-06 18:58:50 +0000
commit4599419e690628dd798c8d037bba4efd8d0b7391 (patch)
tree8e223ef8cf774ae50d57d7f8b3164c5e9bd643a7 /src/debug/macho
parent0e8b7110f6db272e354c73cbf2357e2889be964d (diff)
downloadgo-4599419e690628dd798c8d037bba4efd8d0b7391.tar.xz
debug/macho: use bytes.IndexByte instead of a loop
Simpler, and no doubt faster. Change-Id: Idd401918da07a257de365087721e9ff061e6fd07 Reviewed-on: https://go-review.googlesource.com/98759 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/debug/macho')
-rw-r--r--src/debug/macho/file.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go
index 7b9e83e5a8..da5d9cad4c 100644
--- a/src/debug/macho/file.go
+++ b/src/debug/macho/file.go
@@ -545,8 +545,9 @@ func (f *File) pushSection(sh *Section, r io.ReaderAt) error {
}
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[0:i])
}