Skip to content

Commit

Permalink
handler: minor optimization of result decoding
Browse files Browse the repository at this point in the history
When both an error and a result are reported, check the error before
interfacing the result.
  • Loading branch information
creachadair committed Sep 10, 2021
1 parent 9ec94a8 commit 73131c9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 73131c9

Please sign in to comment.