tests, trie: use slices package for sorting (#27496)
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
@@ -21,12 +21,12 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/ethdb/memorydb"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type kv struct {
|
||||
@@ -34,12 +34,6 @@ type kv struct {
|
||||
t bool
|
||||
}
|
||||
|
||||
type entrySlice []*kv
|
||||
|
||||
func (p entrySlice) Len() int { return len(p) }
|
||||
func (p entrySlice) Less(i, j int) bool { return bytes.Compare(p[i].k, p[j].k) < 0 }
|
||||
func (p entrySlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
type fuzzer struct {
|
||||
input io.Reader
|
||||
exhausted bool
|
||||
@@ -97,14 +91,16 @@ func (f *fuzzer) fuzz() int {
|
||||
if f.exhausted {
|
||||
return 0 // input too short
|
||||
}
|
||||
var entries entrySlice
|
||||
var entries []*kv
|
||||
for _, kv := range vals {
|
||||
entries = append(entries, kv)
|
||||
}
|
||||
if len(entries) <= 1 {
|
||||
return 0
|
||||
}
|
||||
sort.Sort(entries)
|
||||
slices.SortFunc(entries, func(a, b *kv) bool {
|
||||
return bytes.Compare(a.k, b.k) < 0
|
||||
})
|
||||
|
||||
var ok = 0
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user