aboutsummaryrefslogtreecommitdiff
path: root/src/reflect/makefunc.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-17 12:54:31 -0400
committerRuss Cox <rsc@golang.org>2014-10-17 12:54:31 -0400
commit0d81b72e1bf5518b503dbefd0764bfa7e47dcecf (patch)
tree0d8229a48d55faa3f9fce0aeb11e6a4a7d469da1 /src/reflect/makefunc.go
parent5e713062b42110b9f7ccd1c326fab0e42b5b8c35 (diff)
downloadgo-0d81b72e1bf5518b503dbefd0764bfa7e47dcecf.tar.xz
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
Diffstat (limited to 'src/reflect/makefunc.go')
-rw-r--r--src/reflect/makefunc.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/reflect/makefunc.go b/src/reflect/makefunc.go
index 1072c7fabe..d89f7f6811 100644
--- a/src/reflect/makefunc.go
+++ b/src/reflect/makefunc.go
@@ -60,7 +60,7 @@ func MakeFunc(typ Type, fn func(args []Value) (results []Value)) Value {
impl := &makeFuncImpl{code: code, stack: stack, typ: ftyp, fn: fn}
- return Value{t, unsafe.Pointer(impl), flag(Func) << flagKindShift}
+ return Value{t, unsafe.Pointer(impl), flag(Func)}
}
// makeFuncStub is an assembly function that is the code half of
@@ -91,7 +91,7 @@ func makeMethodValue(op string, v Value) Value {
// Ignoring the flagMethod bit, v describes the receiver, not the method type.
fl := v.flag & (flagRO | flagAddr | flagIndir)
- fl |= flag(v.typ.Kind()) << flagKindShift
+ fl |= flag(v.typ.Kind())
rcvr := Value{v.typ, v.ptr, fl}
// v.Type returns the actual type of the method value.
@@ -118,7 +118,7 @@ func makeMethodValue(op string, v Value) Value {
// but we want Interface() and other operations to fail early.
methodReceiver(op, fv.rcvr, fv.method)
- return Value{funcType, unsafe.Pointer(fv), v.flag&flagRO | flag(Func)<<flagKindShift}
+ return Value{funcType, unsafe.Pointer(fv), v.flag&flagRO | flag(Func)}
}
// methodValueCall is an assembly function that is the code half of