diff --git a/core/state/access_list.go b/core/state/access_list.go index a58c2b20ea..1e2d840e6a 100644 --- a/core/state/access_list.go +++ b/core/state/access_list.go @@ -145,7 +145,7 @@ func (al *accessList) Equal(other *accessList) bool { // PrettyPrint prints the contents of the access list in a human-readable form func (al *accessList) PrettyPrint() string { out := new(strings.Builder) - var sortedAddrs []common.Address + sortedAddrs := make([]common.Address, 0, len(al.addresses)) for addr := range al.addresses { sortedAddrs = append(sortedAddrs, addr) } diff --git a/core/state/transient_storage.go b/core/state/transient_storage.go index e63db39eba..8b5ae67fd5 100644 --- a/core/state/transient_storage.go +++ b/core/state/transient_storage.go @@ -70,16 +70,16 @@ func (t transientStorage) Copy() transientStorage { // PrettyPrint prints the contents of the access list in a human-readable form func (t transientStorage) PrettyPrint() string { out := new(strings.Builder) - var sortedAddrs []common.Address + sortedAddrs := make([]common.Address, 0, len(t)) for addr := range t { sortedAddrs = append(sortedAddrs, addr) - slices.SortFunc(sortedAddrs, common.Address.Cmp) } + slices.SortFunc(sortedAddrs, common.Address.Cmp) for _, addr := range sortedAddrs { fmt.Fprintf(out, "%#x:", addr) - var sortedKeys []common.Hash storage := t[addr] + sortedKeys = make([]common.Hash, 0, len(storage)) for key := range storage { sortedKeys = append(sortedKeys, key) }