mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
all: prefer strings.IndexByte over strings.Index
strings.IndexByte was introduced in go1.2 and it can be used effectively wherever the second argument to strings.Index is exactly one byte long. This avoids generating unnecessary string symbols and saves a few calls to strings.Index. Change-Id: I1ab5edb7c4ee9058084cfa57cbcc267c2597e793 Reviewed-on: https://go-review.googlesource.com/65930 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
5e92c41128
commit
f22ba1f247
55 changed files with 81 additions and 81 deletions
|
|
@ -204,7 +204,7 @@ func (p *Package) loadDefines(f *File) {
|
|||
line = strings.TrimSpace(line[8:])
|
||||
|
||||
var key, val string
|
||||
spaceIndex := strings.Index(line, " ")
|
||||
spaceIndex := strings.IndexByte(line, ' ')
|
||||
tabIndex := strings.Index(line, "\t")
|
||||
|
||||
if spaceIndex == -1 && tabIndex == -1 {
|
||||
|
|
@ -364,11 +364,11 @@ func (p *Package) guessKinds(f *File) []*Name {
|
|||
continue
|
||||
}
|
||||
|
||||
c1 := strings.Index(line, ":")
|
||||
c1 := strings.IndexByte(line, ':')
|
||||
if c1 < 0 {
|
||||
continue
|
||||
}
|
||||
c2 := strings.Index(line[c1+1:], ":")
|
||||
c2 := strings.IndexByte(line[c1+1:], ':')
|
||||
if c2 < 0 {
|
||||
continue
|
||||
}
|
||||
|
|
@ -2538,7 +2538,7 @@ func fieldPrefix(fld []*ast.Field) string {
|
|||
if strings.HasPrefix(n.Name, "orig_") || strings.HasPrefix(n.Name, "_") {
|
||||
continue
|
||||
}
|
||||
i := strings.Index(n.Name, "_")
|
||||
i := strings.IndexByte(n.Name, '_')
|
||||
if i < 0 {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue