Skip to content

Commit

Permalink
cmd/evm/internal/t8ntool, core: prealloc map sizes where possible (#2…
Browse files Browse the repository at this point in the history
…9620)

set cap for map in a certain scenario
  • Loading branch information
mask-pp committed Apr 30, 2024
1 parent 8c3fc56 commit fecc8a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/transition.go
Expand Up @@ -296,7 +296,7 @@ func (g Alloc) OnAccount(addr *common.Address, dumpAccount state.DumpAccount) {
balance, _ := new(big.Int).SetString(dumpAccount.Balance, 0)
var storage map[common.Hash]common.Hash
if dumpAccount.Storage != nil {
storage = make(map[common.Hash]common.Hash)
storage = make(map[common.Hash]common.Hash, len(dumpAccount.Storage))
for k, v := range dumpAccount.Storage {
storage[k] = common.HexToHash(v)
}
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Expand Up @@ -1309,7 +1309,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
// Delete block data from the main database.
var (
batch = bc.db.NewBatch()
canonHashes = make(map[common.Hash]struct{})
canonHashes = make(map[common.Hash]struct{}, len(blockChain))
)
for _, block := range blockChain {
canonHashes[block.Hash()] = struct{}{}
Expand Down

0 comments on commit fecc8a0

Please sign in to comment.