From 15650416a20a3225075b7b438e41d1b01bcaced5 Mon Sep 17 00:00:00 2001 From: dbadoy4874 Date: Mon, 11 Jul 2022 17:05:16 +0900 Subject: [PATCH] core, eth: pre-allocate in Copy() --- core/state/state_object.go | 2 +- eth/tracers/logger/logger.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/state/state_object.go b/core/state/state_object.go index 1ffb7eb40228..bc1ca1f40eaf 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -49,7 +49,7 @@ func (s Storage) String() (str string) { } func (s Storage) Copy() Storage { - cpy := make(Storage) + cpy := make(Storage, len(s)) for key, value := range s { cpy[key] = value } diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index fe850d6b3e61..6b087c458734 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -40,7 +40,7 @@ type Storage map[common.Hash]common.Hash // Copy duplicates the current storage. func (s Storage) Copy() Storage { - cpy := make(Storage) + cpy := make(Storage, len(s)) for key, value := range s { cpy[key] = value }