all: prefer bytes.IndexByte over bytes.Index

bytes.IndexByte can be used wherever the second argument to
strings.Index is exactly one byte long, so we do that with this change.

This avoids generating unnecessary string symbols/converison and saves
a few calls to bytes.Index.

Change-Id: If31c775790e01edfece1169e398ad6a754fb4428
Reviewed-on: https://go-review.googlesource.com/66373
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Marvin Stenger 2017-09-21 19:23:51 +02:00 committed by Ian Lance Taylor
parent d2826d3e06
commit 5e42658fc0
4 changed files with 5 additions and 5 deletions

View file

@ -88,7 +88,7 @@ func (u unmarshalerText) MarshalText() ([]byte, error) {
}
func (u *unmarshalerText) UnmarshalText(b []byte) error {
pos := bytes.Index(b, []byte(":"))
pos := bytes.IndexByte(b, ':')
if pos == -1 {
return errors.New("missing separator")
}