From a56558d0920b74b6553185de4aff79c3de534e01 Mon Sep 17 00:00:00 2001 From: maskpp Date: Tue, 29 Jul 2025 13:36:30 +0800 Subject: [PATCH] core/state: preallocate capacity for logs list (#32291) Improvement: preallocate capacity for `logs` at first to avoid reallocating multi times. --- core/state/statedb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index e805885079..7aa6780cfa 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -258,7 +258,7 @@ func (s *StateDB) GetLogs(hash common.Hash, blockNumber uint64, blockHash common } func (s *StateDB) Logs() []*types.Log { - var logs []*types.Log + logs := make([]*types.Log, 0, s.logSize) for _, lgs := range s.logs { logs = append(logs, lgs...) }