From: Josh Bleecher Snyder Date: Mon, 5 Mar 2018 15:40:26 +0000 (-0800) Subject: debug/macho: use bytes.IndexByte instead of a loop X-Git-Tag: go1.11beta1~1326 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4599419e690628dd798c8d037bba4efd8d0b7391;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- 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]) }