From b67c2f007bf93dbd95b41b17db8648468001401b Mon Sep 17 00:00:00 2001 From: greg7mdp Date: Tue, 21 Nov 2023 07:39:19 -0500 Subject: [PATCH] Fix two small performance issues in abi_serializer. --- libraries/chain/abi_serializer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/chain/abi_serializer.cpp b/libraries/chain/abi_serializer.cpp index 0e6232b8af..1cb039fd4a 100644 --- a/libraries/chain/abi_serializer.cpp +++ b/libraries/chain/abi_serializer.cpp @@ -415,6 +415,7 @@ namespace eosio { namespace chain { fc::raw::unpack(stream, size); } EOS_RETHROW_EXCEPTIONS( unpack_exception, "Unable to unpack size of array '${p}'", ("p", ctx.get_path_string()) ) vector vars; + vars.reserve(size); auto h1 = ctx.push_to_path( impl::array_index_path_item{} ); for( decltype(size.value) i = 0; i < size; ++i ) { ctx.set_array_index_of_path_back(i); @@ -501,7 +502,7 @@ namespace eosio { namespace chain { btype->second.second(var, ds, is_array(rtype), is_optional(rtype), ctx.get_yield_function()); } else if ( is_array(rtype) ) { ctx.hint_array_type_if_in_array(); - vector vars = var.get_array(); + const vector& vars = var.get_array(); fc::raw::pack(ds, (fc::unsigned_int)vars.size()); auto h1 = ctx.push_to_path( impl::array_index_path_item{} );