Skip to content

Commit a56558d

Browse files
authored
core/state: preallocate capacity for logs list (ethereum#32291)
Improvement: preallocate capacity for `logs` at first to avoid reallocating multi times.
1 parent eb7aef4 commit a56558d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/state/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (s *StateDB) GetLogs(hash common.Hash, blockNumber uint64, blockHash common
258258
}
259259

260260
func (s *StateDB) Logs() []*types.Log {
261-
var logs []*types.Log
261+
logs := make([]*types.Log, 0, s.logSize)
262262
for _, lgs := range s.logs {
263263
logs = append(logs, lgs...)
264264
}

0 commit comments

Comments
 (0)