]> Cypherpunks repositories - gostls13.git/commitdiff
debug/macho: use bytes.IndexByte instead of a loop
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 5 Mar 2018 15:40:26 +0000 (07:40 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 6 Mar 2018 18:58:50 +0000 (18:58 +0000)
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>
src/debug/macho/file.go

index 7b9e83e5a878f553f4231f00a303dc30b7c91c1a..da5d9cad4cce95435621fddbbdd249e2a72085f4 100644 (file)
@@ -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])
 }