mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 08:53:46 +00:00
all: combine key iterators and sorting in one step
This commit is contained in:
parent
49ef93ea1c
commit
02ee623548
3 changed files with 4 additions and 10 deletions
|
|
@ -54,8 +54,7 @@ func newPriceHeap(basefee *uint256.Int, blobfee *uint256.Int, index map[common.A
|
||||||
// Populate the heap in account sort order. Not really needed in practice,
|
// Populate the heap in account sort order. Not really needed in practice,
|
||||||
// but it makes the heap initialization deterministic and less annoying to
|
// but it makes the heap initialization deterministic and less annoying to
|
||||||
// test in unit tests.
|
// test in unit tests.
|
||||||
heap.addrs = slices.Collect(maps.Keys(index))
|
heap.addrs = slices.SortedFunc(maps.Keys(index), common.Address.Cmp)
|
||||||
slices.SortFunc(heap.addrs, common.Address.Cmp)
|
|
||||||
for i, addr := range heap.addrs {
|
for i, addr := range heap.addrs {
|
||||||
heap.index[addr] = i
|
heap.index[addr] = i
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -323,8 +323,7 @@ func (s *DistinctNetSet) key(ip netip.Addr) netip.Prefix {
|
||||||
|
|
||||||
// String implements fmt.Stringer
|
// String implements fmt.Stringer
|
||||||
func (s DistinctNetSet) String() string {
|
func (s DistinctNetSet) String() string {
|
||||||
keys := slices.Collect(maps.Keys(s.members))
|
keys := slices.SortedFunc(maps.Keys(s.members), func(a, b netip.Prefix) int {
|
||||||
slices.SortFunc(keys, func(a, b netip.Prefix) int {
|
|
||||||
return strings.Compare(a.String(), b.String())
|
return strings.Compare(a.String(), b.String())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -250,15 +250,11 @@ type history struct {
|
||||||
// newHistory constructs the state history object with provided state change set.
|
// newHistory constructs the state history object with provided state change set.
|
||||||
func newHistory(root common.Hash, parent common.Hash, block uint64, accounts map[common.Address][]byte, storages map[common.Address]map[common.Hash][]byte, rawStorageKey bool) *history {
|
func newHistory(root common.Hash, parent common.Hash, block uint64, accounts map[common.Address][]byte, storages map[common.Address]map[common.Hash][]byte, rawStorageKey bool) *history {
|
||||||
var (
|
var (
|
||||||
accountList = slices.Collect(maps.Keys(accounts))
|
accountList = slices.SortedFunc(maps.Keys(accounts), common.Address.Cmp)
|
||||||
storageList = make(map[common.Address][]common.Hash)
|
storageList = make(map[common.Address][]common.Hash)
|
||||||
)
|
)
|
||||||
slices.SortFunc(accountList, common.Address.Cmp)
|
|
||||||
|
|
||||||
for addr, slots := range storages {
|
for addr, slots := range storages {
|
||||||
slist := slices.Collect(maps.Keys(slots))
|
storageList[addr] = slices.SortedFunc(maps.Keys(slots), common.Hash.Cmp)
|
||||||
slices.SortFunc(slist, common.Hash.Cmp)
|
|
||||||
storageList[addr] = slist
|
|
||||||
}
|
}
|
||||||
version := historyVersion
|
version := historyVersion
|
||||||
if !rawStorageKey {
|
if !rawStorageKey {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue