expr
expr copied to clipboard
Remove reflect from FastCall path
trafficstars
Even if a function is defined in a fetcher, expr still used FetchFn and uses reflection unlike pure variables in a struct. FetchFn is guaranteed to use reflection.
func FetchFn(from interface{}, name string) reflect.Value {
v := reflect.ValueOf(from)
// Methods can be defined on any type.
if v.NumMethod() > 0 {
method := v.MethodByName(name) //MethodByName utilizes reflection. Can this be avoided all together?
if method.IsValid() {
return method
}
}
Thank you.
Originally posted by @gitperson1980 in https://github.com/antonmedv/expr/issues/217#issuecomment-1011276835