cmd/evm/internal/t8ntool, core: prealloc map sizes where possible (#29620)

set cap for map in a certain scenario
pull/29362/head
maskpp 7 months ago committed by GitHub
parent 8c3fc56d7f
commit fecc8a0f4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      cmd/evm/internal/t8ntool/transition.go
  2. 2
      core/blockchain.go

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

@ -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{}{}

Loading…
Cancel
Save