From 344d01e2be231e328935c4c215e5c54c1c9e3761 Mon Sep 17 00:00:00 2001 From: Lessa <230214854+adblesss@users.noreply.github.com> Date: Tue, 27 Jan 2026 20:51:15 -0500 Subject: [PATCH] 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. --- core/rawdb/chain_iterator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/rawdb/chain_iterator.go b/core/rawdb/chain_iterator.go index 713c3d8ae2..f846d4d16c 100644 --- a/core/rawdb/chain_iterator.go +++ b/core/rawdb/chain_iterator.go @@ -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,