core/state: preallocate capacity for logs list (#32291)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

Improvement: preallocate capacity for `logs` at first to avoid
reallocating multi times.
This commit is contained in:
maskpp 2025-07-29 13:36:30 +08:00 committed by GitHub
parent eb7aef45a7
commit a56558d092
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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...)
}