reflect: a few microoptimizations

Replace i < 0 || i >= x with uint(i) >= uint(x).
Shorten a few other code sequences.
Move the kind bits to the bottom of the flag word, to avoid shifts.

LGTM=r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/159020043
This commit is contained in:
Russ Cox 2014-10-17 12:54:31 -04:00
parent 5e713062b4
commit 0d81b72e1b
3 changed files with 91 additions and 122 deletions

View file

@ -490,7 +490,7 @@ func (t *uncommonType) Method(i int) (m Method) {
if p.name != nil {
m.Name = *p.name
}
fl := flag(Func) << flagKindShift
fl := flag(Func)
if p.pkgPath != nil {
m.PkgPath = *p.pkgPath
fl |= flagRO