mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-23 19:37:46 +08:00
fix: don't sort the output of Entries()
only sort SortedEntries() License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
parent
acc714823b
commit
8d4d5b86ef
@ -63,26 +63,13 @@ func (w *ThreadSafe) Contains(k u.Key) bool {
|
||||
func (w *ThreadSafe) Entries() []*Entry {
|
||||
w.lk.RLock()
|
||||
defer w.lk.RUnlock()
|
||||
var es entrySlice
|
||||
for _, e := range w.set {
|
||||
es = append(es, e)
|
||||
}
|
||||
// TODO rename SortedEntries (state that they're sorted so callers know
|
||||
// they're paying an expense)
|
||||
sort.Sort(es)
|
||||
return es
|
||||
return w.Wantlist.Entries()
|
||||
}
|
||||
|
||||
func (w *ThreadSafe) SortedEntries() []*Entry {
|
||||
w.lk.RLock()
|
||||
defer w.lk.RUnlock()
|
||||
var es entrySlice
|
||||
|
||||
for _, e := range w.set {
|
||||
es = append(es, e)
|
||||
}
|
||||
sort.Sort(es)
|
||||
return es
|
||||
return w.Wantlist.SortedEntries()
|
||||
}
|
||||
|
||||
func (w *Wantlist) Add(k u.Key, priority int) {
|
||||
@ -106,17 +93,14 @@ func (w *Wantlist) Contains(k u.Key) bool {
|
||||
|
||||
func (w *Wantlist) Entries() []*Entry {
|
||||
var es entrySlice
|
||||
|
||||
for _, e := range w.set {
|
||||
es = append(es, e)
|
||||
}
|
||||
sort.Sort(es)
|
||||
return es
|
||||
}
|
||||
|
||||
func (w *Wantlist) SortedEntries() []*Entry {
|
||||
var es entrySlice
|
||||
|
||||
for _, e := range w.set {
|
||||
es = append(es, e)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user