From 73131c9f637ac6de0ef22da6f5549ce2b0d74dcf Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Fri, 10 Sep 2021 07:41:16 -0700 Subject: [PATCH] handler: minor optimization of result decoding When both an error and a result are reported, check the error before interfacing the result. --- handler/handler.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/handler/handler.go b/handler/handler.go index 45ecb3f..066d7f0 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -195,11 +195,10 @@ func (fi *FuncInfo) Wrap() Func { } else { // The function returns both a value and an error. decodeOut = func(vals []reflect.Value) (interface{}, error) { - out, oerr := vals[0].Interface(), vals[1].Interface() - if oerr != nil { + if oerr := vals[1].Interface(); oerr != nil { return nil, oerr.(error) } - return out, nil + return vals[0].Interface(), nil } }