Commit aa00d974 authored by Tobias Klauser's avatar Tobias Klauser Committed by Tobias Klauser

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: default avatarIan Lance Taylor <iant@golang.org>
parent 06572356
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package pe package pe
import ( import (
"bytes"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"io" "io"
...@@ -13,8 +14,9 @@ import ( ...@@ -13,8 +14,9 @@ import (
// cstring converts ASCII byte sequence b to string. // cstring converts ASCII byte sequence b to string.
// It stops once it finds 0 or reaches end of b. // It stops once it finds 0 or reaches end of b.
func cstring(b []byte) string { func cstring(b []byte) string {
var i int i := bytes.IndexByte(b, 0)
for i = 0; i < len(b) && b[i] != 0; i++ { if i == -1 {
i = len(b)
} }
return string(b[:i]) return string(b[:i])
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment