From 47d31251b8d284ecf735af002663c911e446de59 Mon Sep 17 00:00:00 2001 From: MariusVanDerWijden Date: Thu, 13 Feb 2020 16:49:04 +0100 Subject: [PATCH] accounts/abi: reduced usage of arguments.LengthNonIndexed --- accounts/abi/argument.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/accounts/abi/argument.go b/accounts/abi/argument.go index 27af0d8a66..ce98808b3e 100644 --- a/accounts/abi/argument.go +++ b/accounts/abi/argument.go @@ -205,10 +205,11 @@ func unpack(t *Type, dst interface{}, src interface{}) error { // unpackAtomic unpacks ( hexdata -> go ) a single value func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues interface{}) error { - if arguments.LengthNonIndexed() == 0 { + nonIndexedArgs := arguments.NonIndexed() + if len(nonIndexedArgs) == 0 { return nil } - argument := arguments.NonIndexed()[0] + argument := nonIndexedArgs[0] elem := reflect.ValueOf(v).Elem() if elem.Kind() == reflect.Struct && argument.Type.T != TupleTy { @@ -282,10 +283,11 @@ func (arguments Arguments) unpackTuple(v interface{}, marshalledValues []interfa // without supplying a struct to unpack into. Instead, this method returns a list containing the // values. An atomic argument will be a list with one element. func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) { - retval := make([]interface{}, 0, arguments.LengthNonIndexed()) + nonIndexedArgs := arguments.NonIndexed() + retval := make([]interface{}, 0, len(nonIndexedArgs)) virtualArgs := 0 - for index, arg := range arguments.NonIndexed() { - marshalledValue, err := ToGoType((index+virtualArgs)*32, arg.Type, data) + for index, arg := range nonIndexedArgs { + marshalledValue, err := toGoType((index+virtualArgs)*32, arg.Type, data) if arg.Type.T == ArrayTy && !isDynamicType(arg.Type) { // If we have a static array, like [3]uint256, these are coded as // just like uint256,uint256,uint256.