mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
core/state: move slices.SortFunc out of a for loop
This commit is contained in:
parent
a56558d092
commit
f7eae65763
2 changed files with 4 additions and 4 deletions
|
|
@ -145,7 +145,7 @@ func (al *accessList) Equal(other *accessList) bool {
|
||||||
// PrettyPrint prints the contents of the access list in a human-readable form
|
// PrettyPrint prints the contents of the access list in a human-readable form
|
||||||
func (al *accessList) PrettyPrint() string {
|
func (al *accessList) PrettyPrint() string {
|
||||||
out := new(strings.Builder)
|
out := new(strings.Builder)
|
||||||
var sortedAddrs []common.Address
|
sortedAddrs := make([]common.Address, 0, len(al.addresses))
|
||||||
for addr := range al.addresses {
|
for addr := range al.addresses {
|
||||||
sortedAddrs = append(sortedAddrs, addr)
|
sortedAddrs = append(sortedAddrs, addr)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,16 +70,16 @@ func (t transientStorage) Copy() transientStorage {
|
||||||
// PrettyPrint prints the contents of the access list in a human-readable form
|
// PrettyPrint prints the contents of the access list in a human-readable form
|
||||||
func (t transientStorage) PrettyPrint() string {
|
func (t transientStorage) PrettyPrint() string {
|
||||||
out := new(strings.Builder)
|
out := new(strings.Builder)
|
||||||
var sortedAddrs []common.Address
|
sortedAddrs := make([]common.Address, 0, len(t))
|
||||||
for addr := range t {
|
for addr := range t {
|
||||||
sortedAddrs = append(sortedAddrs, addr)
|
sortedAddrs = append(sortedAddrs, addr)
|
||||||
slices.SortFunc(sortedAddrs, common.Address.Cmp)
|
|
||||||
}
|
}
|
||||||
|
slices.SortFunc(sortedAddrs, common.Address.Cmp)
|
||||||
|
|
||||||
for _, addr := range sortedAddrs {
|
for _, addr := range sortedAddrs {
|
||||||
fmt.Fprintf(out, "%#x:", addr)
|
fmt.Fprintf(out, "%#x:", addr)
|
||||||
var sortedKeys []common.Hash
|
|
||||||
storage := t[addr]
|
storage := t[addr]
|
||||||
|
sortedKeys = make([]common.Hash, 0, len(storage))
|
||||||
for key := range storage {
|
for key := range storage {
|
||||||
sortedKeys = append(sortedKeys, key)
|
sortedKeys = append(sortedKeys, key)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue