mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 13:48:01 +00:00
all: use Go 1.22 range-over-int
Updates #11058 Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
068db1f972
commit
7c1d6e35a5
@@ -262,7 +262,7 @@ func (v Slice[T]) AsSlice() []T {
|
||||
//
|
||||
// As it runs in O(n) time, use with care.
|
||||
func (v Slice[T]) IndexFunc(f func(T) bool) int {
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
for i := range v.Len() {
|
||||
if f(v.At(i)) {
|
||||
return i
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ type viewStruct struct {
|
||||
|
||||
func BenchmarkSliceIteration(b *testing.B) {
|
||||
var data []viewStruct
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := range 10000 {
|
||||
data = append(data, viewStruct{Int: i})
|
||||
}
|
||||
b.ResetTimer()
|
||||
@@ -33,7 +33,7 @@ func BenchmarkSliceIteration(b *testing.B) {
|
||||
dv := SliceOf(data)
|
||||
for it := 0; it < b.N; it++ {
|
||||
sum := 0
|
||||
for i := 0; i < dv.Len(); i++ {
|
||||
for i := range dv.Len() {
|
||||
sum += dv.At(i).Int
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func TestSliceMapKey(t *testing.T) {
|
||||
}
|
||||
|
||||
wantDiff := []Slice[string]{nilSlice, empty, sub1, sub2, sub3, u3}
|
||||
for i := 0; i < len(wantDiff); i++ {
|
||||
for i := range len(wantDiff) {
|
||||
for j := i + 1; j < len(wantDiff); j++ {
|
||||
si, sj := wantDiff[i], wantDiff[j]
|
||||
ki, kj := wantDiff[i].MapKey(), wantDiff[j].MapKey()
|
||||
|
Reference in New Issue
Block a user