mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 03:49:27 +01:00
Merge pull request #1948 from slingamn/reverse_again
remove history.ReverseCorrespondents in favor of generics
This commit is contained in:
commit
dea2e7961a
@ -262,7 +262,7 @@ func (list *Buffer) listCorrespondents(start, end Selector, cutoff time.Time, li
|
||||
}
|
||||
|
||||
if !ascending {
|
||||
ReverseCorrespondents(results)
|
||||
utils.ReverseSlice(results)
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -6,6 +6,8 @@ package history
|
||||
import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/ergochat/ergo/irc/utils"
|
||||
)
|
||||
|
||||
type TargetListing struct {
|
||||
@ -33,8 +35,8 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
|
||||
results = make([]TargetListing, 0, prealloc)
|
||||
|
||||
if !ascending {
|
||||
ReverseCorrespondents(base)
|
||||
ReverseCorrespondents(extra)
|
||||
utils.ReverseSlice(base)
|
||||
utils.ReverseSlice(extra)
|
||||
}
|
||||
|
||||
for len(results) < limit {
|
||||
@ -64,18 +66,11 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
|
||||
}
|
||||
|
||||
if !ascending {
|
||||
ReverseCorrespondents(results)
|
||||
utils.ReverseSlice(results)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ReverseCorrespondents(results []TargetListing) {
|
||||
// lol, generics when?
|
||||
for i, j := 0, len(results)-1; i < j; i, j = i+1, j-1 {
|
||||
results[i], results[j] = results[j], results[i]
|
||||
}
|
||||
}
|
||||
|
||||
func SortCorrespondents(list []TargetListing) {
|
||||
sort.Slice(list, func(i, j int) bool {
|
||||
return list[i].Time.Before(list[j].Time)
|
||||
|
@ -964,7 +964,7 @@ func (mysql *MySQL) listCorrespondentsInternal(ctx context.Context, target strin
|
||||
}
|
||||
|
||||
if !ascending {
|
||||
history.ReverseCorrespondents(results)
|
||||
utils.ReverseSlice(results)
|
||||
}
|
||||
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user