Skip to content

Commit fecc8a0

Browse files
authored
cmd/evm/internal/t8ntool, core: prealloc map sizes where possible (#29620)
set cap for map in a certain scenario
1 parent 8c3fc56 commit fecc8a0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cmd/evm/internal/t8ntool/transition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (g Alloc) OnAccount(addr *common.Address, dumpAccount state.DumpAccount) {
296296
balance, _ := new(big.Int).SetString(dumpAccount.Balance, 0)
297297
var storage map[common.Hash]common.Hash
298298
if dumpAccount.Storage != nil {
299-
storage = make(map[common.Hash]common.Hash)
299+
storage = make(map[common.Hash]common.Hash, len(dumpAccount.Storage))
300300
for k, v := range dumpAccount.Storage {
301301
storage[k] = common.HexToHash(v)
302302
}

core/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
13091309
// Delete block data from the main database.
13101310
var (
13111311
batch = bc.db.NewBatch()
1312-
canonHashes = make(map[common.Hash]struct{})
1312+
canonHashes = make(map[common.Hash]struct{}, len(blockChain))
13131313
)
13141314
for _, block := range blockChain {
13151315
canonHashes[block.Hash()] = struct{}{}

0 commit comments

Comments
 (0)