@@ -71,10 +71,10 @@ import (
71
71
// InterfaceSlice is a helper type for sorting interface
72
72
// slices according to some slice-specific sort criteria.
73
73
74
- type comparer func (x , y interface {} ) bool
74
+ type comparer func (x , y any ) bool
75
75
76
76
type interfaceSlice struct {
77
- slice []interface {}
77
+ slice []any
78
78
less comparer
79
79
}
80
80
@@ -87,7 +87,7 @@ type interfaceSlice struct {
87
87
// runs. For instance, a RunList containing pairs (x, y) may be compressed
88
88
// into a RunList containing pair runs (x, {y}) where each run consists of
89
89
// a list of y's with the same x.
90
- type RunList []interface {}
90
+ type RunList []any
91
91
92
92
func (h RunList ) sort (less comparer ) {
93
93
sort .Sort (& interfaceSlice {h , less })
@@ -99,7 +99,7 @@ func (p *interfaceSlice) Swap(i, j int) { p.slice[i], p.slice[j] = p.slice[
99
99
100
100
// Compress entries which are the same according to a sort criteria
101
101
// (specified by less) into "runs".
102
- func (h RunList ) reduce (less comparer , newRun func (h RunList ) interface {} ) RunList {
102
+ func (h RunList ) reduce (less comparer , newRun func (h RunList ) any ) RunList {
103
103
if len (h ) == 0 {
104
104
return nil
105
105
}
@@ -143,10 +143,10 @@ func (k KindRun) Less(i, j int) bool { return k[i].Lori() < k[j].Lori() }
143
143
func (k KindRun ) Swap (i , j int ) { k [i ], k [j ] = k [j ], k [i ] }
144
144
145
145
// FileRun contents are sorted by Kind for the reduction into KindRuns.
146
- func lessKind (x , y interface {} ) bool { return x .(SpotInfo ).Kind () < y .(SpotInfo ).Kind () }
146
+ func lessKind (x , y any ) bool { return x .(SpotInfo ).Kind () < y .(SpotInfo ).Kind () }
147
147
148
148
// newKindRun allocates a new KindRun from the SpotInfo run h.
149
- func newKindRun (h RunList ) interface {} {
149
+ func newKindRun (h RunList ) any {
150
150
run := make (KindRun , len (h ))
151
151
for i , x := range h {
152
152
run [i ] = x .(SpotInfo )
@@ -214,7 +214,7 @@ type FileRun struct {
214
214
}
215
215
216
216
// Spots are sorted by file path for the reduction into FileRuns.
217
- func lessSpot (x , y interface {} ) bool {
217
+ func lessSpot (x , y any ) bool {
218
218
fx := x .(Spot ).File
219
219
fy := y .(Spot ).File
220
220
// same as "return fx.Path() < fy.Path()" but w/o computing the file path first
@@ -224,7 +224,7 @@ func lessSpot(x, y interface{}) bool {
224
224
}
225
225
226
226
// newFileRun allocates a new FileRun from the Spot run h.
227
- func newFileRun (h RunList ) interface {} {
227
+ func newFileRun (h RunList ) any {
228
228
file := h [0 ].(Spot ).File
229
229
230
230
// reduce the list of Spots into a list of KindRuns
@@ -257,12 +257,12 @@ func (p *PakRun) Less(i, j int) bool { return p.Files[i].File.Name < p.Files[j].
257
257
func (p * PakRun ) Swap (i , j int ) { p .Files [i ], p .Files [j ] = p .Files [j ], p .Files [i ] }
258
258
259
259
// FileRuns are sorted by package for the reduction into PakRuns.
260
- func lessFileRun (x , y interface {} ) bool {
260
+ func lessFileRun (x , y any ) bool {
261
261
return x .(* FileRun ).File .Pak .less (y .(* FileRun ).File .Pak )
262
262
}
263
263
264
264
// newPakRun allocates a new PakRun from the *FileRun run h.
265
- func newPakRun (h RunList ) interface {} {
265
+ func newPakRun (h RunList ) any {
266
266
pak := h [0 ].(* FileRun ).File .Pak
267
267
files := make ([]* FileRun , len (h ))
268
268
for i , x := range h {
@@ -280,7 +280,7 @@ func newPakRun(h RunList) interface{} {
280
280
type HitList []* PakRun
281
281
282
282
// PakRuns are sorted by package.
283
- func lessPakRun (x , y interface {} ) bool { return x .(* PakRun ).Pak .less (y .(* PakRun ).Pak ) }
283
+ func lessPakRun (x , y any ) bool { return x .(* PakRun ).Pak .less (y .(* PakRun ).Pak ) }
284
284
285
285
func reduce (h0 RunList ) HitList {
286
286
// reduce a list of Spots into a list of FileRuns
@@ -325,10 +325,10 @@ type AltWords struct {
325
325
}
326
326
327
327
// wordPairs are sorted by their canonical spelling.
328
- func lessWordPair (x , y interface {} ) bool { return x .(* wordPair ).canon < y .(* wordPair ).canon }
328
+ func lessWordPair (x , y any ) bool { return x .(* wordPair ).canon < y .(* wordPair ).canon }
329
329
330
330
// newAltWords allocates a new AltWords from the *wordPair run h.
331
- func newAltWords (h RunList ) interface {} {
331
+ func newAltWords (h RunList ) any {
332
332
canon := h [0 ].(* wordPair ).canon
333
333
alts := make ([]string , len (h ))
334
334
for i , x := range h {
@@ -1159,7 +1159,7 @@ func (x *Index) WriteTo(w io.Writer) (n int64, err error) {
1159
1159
return 0 , err
1160
1160
}
1161
1161
if fulltext {
1162
- encode := func (x interface {} ) error {
1162
+ encode := func (x any ) error {
1163
1163
return gob .NewEncoder (w ).Encode (x )
1164
1164
}
1165
1165
if err := x .fset .Write (encode ); err != nil {
@@ -1199,7 +1199,7 @@ func (x *Index) ReadFrom(r io.Reader) (n int64, err error) {
1199
1199
x .opts = fx .Opts
1200
1200
if fx .Fulltext {
1201
1201
x .fset = token .NewFileSet ()
1202
- decode := func (x interface {} ) error {
1202
+ decode := func (x any ) error {
1203
1203
return gob .NewDecoder (r ).Decode (x )
1204
1204
}
1205
1205
if err := x .fset .Read (decode ); err != nil {
0 commit comments