diff --git a/irc/history/history.go b/irc/history/history.go index fda91c03..75d6298d 100644 --- a/irc/history/history.go +++ b/irc/history/history.go @@ -262,7 +262,7 @@ func (list *Buffer) listCorrespondents(start, end Selector, cutoff time.Time, li } if !ascending { - ReverseCorrespondents(results) + utils.ReverseSlice(results) } return diff --git a/irc/history/targets.go b/irc/history/targets.go index 39a0c209..39a8c635 100644 --- a/irc/history/targets.go +++ b/irc/history/targets.go @@ -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) diff --git a/irc/mysql/history.go b/irc/mysql/history.go index dddef81e..9b69bae1 100644 --- a/irc/mysql/history.go +++ b/irc/mysql/history.go @@ -964,7 +964,7 @@ func (mysql *MySQL) listCorrespondentsInternal(ctx context.Context, target strin } if !ascending { - history.ReverseCorrespondents(results) + utils.ReverseSlice(results) } return