From 44093548332bca5879df382acefa9c59829d5ff9 Mon Sep 17 00:00:00 2001 From: pantianying <601666418@qq.com> Date: Mon, 30 Dec 2019 11:28:28 +0800 Subject: [PATCH] optimize code style --- filter/impl/generic_filter.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/filter/impl/generic_filter.go b/filter/impl/generic_filter.go index 35aadb11a..48b1a3893 100644 --- a/filter/impl/generic_filter.go +++ b/filter/impl/generic_filter.go @@ -47,22 +47,21 @@ type GenericFilter struct{} func (ef *GenericFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { if invocation.MethodName() == constant.GENERIC && len(invocation.Arguments()) == 3 { oldArguments := invocation.Arguments() - var newParams []hessian.Object + if oldParams, ok := oldArguments[2].([]interface{}); ok { + newParams := make([]hessian.Object, len(oldParams)) for i := range oldParams { newParams = append(newParams, hessian.Object(struct2MapAll(oldParams[i]))) } - } else { - return invoker.Invoke(invocation) - } - newArguments := []interface{}{ - oldArguments[0], - oldArguments[1], - newParams, + newArguments := []interface{}{ + oldArguments[0], + oldArguments[1], + newParams, + } + newInvocation := invocation2.NewRPCInvocation(invocation.MethodName(), newArguments, invocation.Attachments()) + newInvocation.SetReply(invocation.Reply()) + return invoker.Invoke(newInvocation) } - newInvocation := invocation2.NewRPCInvocation(invocation.MethodName(), newArguments, invocation.Attachments()) - newInvocation.SetReply(invocation.Reply()) - return invoker.Invoke(newInvocation) } return invoker.Invoke(invocation) } -- GitLab