mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
core/rawdb: preallocate slice in iterateTransactions (#33690)
Preallocate hashes slice with known length instead of using append in a loop. This avoids multiple reallocations during transaction indexing.
This commit is contained in:
parent
56be36f672
commit
344d01e2be
1 changed files with 3 additions and 3 deletions
|
|
@ -153,9 +153,9 @@ func iterateTransactions(db ethdb.Database, from uint64, to uint64, reverse bool
|
|||
err: err,
|
||||
}
|
||||
} else {
|
||||
var hashes []common.Hash
|
||||
for _, tx := range body.Transactions {
|
||||
hashes = append(hashes, tx.Hash())
|
||||
hashes := make([]common.Hash, len(body.Transactions))
|
||||
for i, tx := range body.Transactions {
|
||||
hashes[i] = tx.Hash()
|
||||
}
|
||||
result = &blockTxHashes{
|
||||
hashes: hashes,
|
||||
|
|
|
|||
Loading…
Reference in a new issue