Skip to content

Commit 845ac68

Browse files
authored
Merge pull request #1307 from CortexFoundation/dev
core: preallocate maps in TxPool helper methods
2 parents 7201f64 + f2c8ca3 commit 845ac68

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/tx_pool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,11 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
500500
pool.mu.Lock()
501501
defer pool.mu.Unlock()
502502

503-
pending := make(map[common.Address]types.Transactions)
503+
pending := make(map[common.Address]types.Transactions, len(pool.pending))
504504
for addr, list := range pool.pending {
505505
pending[addr] = list.Flatten()
506506
}
507-
queued := make(map[common.Address]types.Transactions)
507+
queued := make(map[common.Address]types.Transactions, len(pool.queue))
508508
for addr, list := range pool.queue {
509509
queued[addr] = list.Flatten()
510510
}
@@ -1547,7 +1547,7 @@ type accountSet struct {
15471547
// derivations.
15481548
func newAccountSet(signer types.Signer, addrs ...common.Address) *accountSet {
15491549
as := &accountSet{
1550-
accounts: make(map[common.Address]struct{}),
1550+
accounts: make(map[common.Address]struct{}, len(addrs)),
15511551
signer: signer,
15521552
}
15531553
for _, addr := range addrs {

0 commit comments

Comments
 (0)