Commit c8f74e55 authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

fix: don't sort the output of Entries()

only sort SortedEntries()

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent b3712aae
......@@ -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)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment