Skip to content

Commit

Permalink
core: preallocate maps in TxPool helper methods (ethereum#25737)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadoy authored and blakehhuynh committed Oct 3, 2022
1 parent e0735c9 commit 7fdc6d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/tx_pool.go
Expand Up @@ -498,11 +498,11 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
pool.mu.Lock()
defer pool.mu.Unlock()

pending := make(map[common.Address]types.Transactions)
pending := make(map[common.Address]types.Transactions, len(pool.pending))
for addr, list := range pool.pending {
pending[addr] = list.Flatten()
}
queued := make(map[common.Address]types.Transactions)
queued := make(map[common.Address]types.Transactions, len(pool.queue))
for addr, list := range pool.queue {
queued[addr] = list.Flatten()
}
Expand Down Expand Up @@ -1588,7 +1588,7 @@ type accountSet struct {
// derivations.
func newAccountSet(signer types.Signer, addrs ...common.Address) *accountSet {
as := &accountSet{
accounts: make(map[common.Address]struct{}),
accounts: make(map[common.Address]struct{}, len(addrs)),
signer: signer,
}
for _, addr := range addrs {
Expand Down

0 comments on commit 7fdc6d0

Please sign in to comment.