mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
use genericized slice-reversing function
This commit is contained in:
parent
2a3b8e648c
commit
2df5fb1956
3 changed files with 11 additions and 9 deletions
|
|
@ -4,9 +4,10 @@
|
|||
package history
|
||||
|
||||
import (
|
||||
"github.com/ergochat/ergo/irc/utils"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ergochat/ergo/irc/utils"
|
||||
)
|
||||
|
||||
type ItemType uint
|
||||
|
|
@ -55,12 +56,6 @@ func (item *Item) HasMsgid(msgid string) bool {
|
|||
|
||||
type Predicate func(item *Item) (matches bool)
|
||||
|
||||
func Reverse(results []Item) {
|
||||
for i, j := 0, len(results)-1; i < j; i, j = i+1, j-1 {
|
||||
results[i], results[j] = results[j], results[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Buffer is a ring buffer holding message/event history for a channel or user
|
||||
type Buffer struct {
|
||||
sync.RWMutex
|
||||
|
|
@ -160,7 +155,7 @@ func (list *Buffer) betweenHelper(start, end Selector, cutoff time.Time, pred Pr
|
|||
|
||||
defer func() {
|
||||
if !ascending {
|
||||
Reverse(results)
|
||||
utils.ReverseSlice(results)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue