Przeglądaj źródła

remove history.ReverseCorrespondents in favor of generics

tags/v2.10.0-rc1
Shivaram Lingamneni 2 lat temu
rodzic
commit
c87dead39b
3 zmienionych plików z 7 dodań i 12 usunięć
  1. 1
    1
      irc/history/history.go
  2. 5
    10
      irc/history/targets.go
  3. 1
    1
      irc/mysql/history.go

+ 1
- 1
irc/history/history.go Wyświetl plik

@@ -262,7 +262,7 @@ func (list *Buffer) listCorrespondents(start, end Selector, cutoff time.Time, li
262 262
 	}
263 263
 
264 264
 	if !ascending {
265
-		ReverseCorrespondents(results)
265
+		utils.ReverseSlice(results)
266 266
 	}
267 267
 
268 268
 	return

+ 5
- 10
irc/history/targets.go Wyświetl plik

@@ -6,6 +6,8 @@ package history
6 6
 import (
7 7
 	"sort"
8 8
 	"time"
9
+
10
+	"github.com/ergochat/ergo/irc/utils"
9 11
 )
10 12
 
11 13
 type TargetListing struct {
@@ -33,8 +35,8 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
33 35
 	results = make([]TargetListing, 0, prealloc)
34 36
 
35 37
 	if !ascending {
36
-		ReverseCorrespondents(base)
37
-		ReverseCorrespondents(extra)
38
+		utils.ReverseSlice(base)
39
+		utils.ReverseSlice(extra)
38 40
 	}
39 41
 
40 42
 	for len(results) < limit {
@@ -64,18 +66,11 @@ func MergeTargets(base []TargetListing, extra []TargetListing, start, end time.T
64 66
 	}
65 67
 
66 68
 	if !ascending {
67
-		ReverseCorrespondents(results)
69
+		utils.ReverseSlice(results)
68 70
 	}
69 71
 	return
70 72
 }
71 73
 
72
-func ReverseCorrespondents(results []TargetListing) {
73
-	// lol, generics when?
74
-	for i, j := 0, len(results)-1; i < j; i, j = i+1, j-1 {
75
-		results[i], results[j] = results[j], results[i]
76
-	}
77
-}
78
-
79 74
 func SortCorrespondents(list []TargetListing) {
80 75
 	sort.Slice(list, func(i, j int) bool {
81 76
 		return list[i].Time.Before(list[j].Time)

+ 1
- 1
irc/mysql/history.go Wyświetl plik

@@ -964,7 +964,7 @@ func (mysql *MySQL) listCorrespondentsInternal(ctx context.Context, target strin
964 964
 	}
965 965
 
966 966
 	if !ascending {
967
-		history.ReverseCorrespondents(results)
967
+		utils.ReverseSlice(results)
968 968
 	}
969 969
 
970 970
 	return

Ładowanie…
Anuluj
Zapisz