diff --git a/irc/history/history.go b/irc/history/history.go index 75d6298d..ef7e4d9f 100644 --- a/irc/history/history.go +++ b/irc/history/history.go @@ -4,6 +4,7 @@ package history import ( + "slices" "sync" "time" @@ -155,7 +156,7 @@ func (list *Buffer) betweenHelper(start, end Selector, cutoff time.Time, pred Pr defer func() { if !ascending { - utils.ReverseSlice(results) + slices.Reverse(results) } }() @@ -262,7 +263,7 @@ func (list *Buffer) listCorrespondents(start, end Selector, cutoff time.Time, li } if !ascending { - utils.ReverseSlice(results) + slices.Reverse(results) } return diff --git a/irc/history/targets.go b/irc/history/targets.go index 39a8c635..d2fdf67c 100644 --- a/irc/history/targets.go +++ b/irc/history/targets.go @@ -4,10 +4,9 @@ package history import ( + "slices" "sort" "time" - - "github.com/ergochat/ergo/irc/utils" ) type TargetListing struct { @@ -35,8 +34,8 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T results = make([]TargetListing, 0, prealloc) if !ascending { - utils.ReverseSlice(base) - utils.ReverseSlice(extra) + slices.Reverse(base) + slices.Reverse(extra) } for len(results) < limit { @@ -66,7 +65,7 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T } if !ascending { - utils.ReverseSlice(results) + slices.Reverse(results) } return } diff --git a/irc/mysql/history.go b/irc/mysql/history.go index 4cb985f4..4b967104 100644 --- a/irc/mysql/history.go +++ b/irc/mysql/history.go @@ -11,6 +11,7 @@ import ( "fmt" "io" "runtime/debug" + "slices" "strings" "sync" "sync/atomic" @@ -917,7 +918,7 @@ func (mysql *MySQL) betweenTimestamps(ctx context.Context, target, correspondent results, err = mysql.selectItems(ctx, queryBuf.String(), args...) if err == nil && !ascending { - utils.ReverseSlice(results) + slices.Reverse(results) } return } @@ -965,7 +966,7 @@ func (mysql *MySQL) listCorrespondentsInternal(ctx context.Context, target strin } if !ascending { - utils.ReverseSlice(results) + slices.Reverse(results) } return diff --git a/irc/utils/types.go b/irc/utils/types.go index 8c2ca4eb..47883a47 100644 --- a/irc/utils/types.go +++ b/irc/utils/types.go @@ -36,13 +36,6 @@ func CopyMap[K comparable, V any](input map[K]V) (result map[K]V) { return } -// reverse the order of a slice in place -func ReverseSlice[T any](results []T) { - for i, j := 0, len(results)-1; i < j; i, j = i+1, j-1 { - results[i], results[j] = results[j], results[i] - } -} - func SliceContains[T comparable](slice []T, elem T) (result bool) { for _, t := range slice { if elem == t {