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:
Brad Fitzpatrick
2024-04-16 13:15:13 -07:00
committed by Brad Fitzpatrick
parent 068db1f972
commit 7c1d6e35a5
143 changed files with 280 additions and 282 deletions

View File

@@ -91,7 +91,7 @@ func AppendSliceElem[K ~string, S []E, E any](m map[K]S, k K, vs ...E) {
}
func isLowerASCII(s string) bool {
for i := 0; i < len(s); i++ {
for i := range len(s) {
if c := s[i]; c >= utf8.RuneSelf || ('A' <= c && c <= 'Z') {
return false
}

View File

@@ -112,13 +112,13 @@ func Benchmark(b *testing.B) {
b.Run("Get", func(b *testing.B) {
b.Run("Naive", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
testSink = testMap[strings.ToLower(key)]
}
})
b.Run("NoCase", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
testSink = Get(testMap, key)
}
})
@@ -127,7 +127,7 @@ func Benchmark(b *testing.B) {
b.Run("Naive", func(b *testing.B) {
b.ReportAllocs()
testMap[strings.ToLower(key)] = testValue
for i := 0; i < b.N; i++ {
for range b.N {
testMap[strings.ToLower(key)] = testValue
}
xmaps.Clear(testMap)
@@ -135,7 +135,7 @@ func Benchmark(b *testing.B) {
b.Run("NoCase", func(b *testing.B) {
b.ReportAllocs()
Set(testMap, key, testValue)
for i := 0; i < b.N; i++ {
for range b.N {
Set(testMap, key, testValue)
}
xmaps.Clear(testMap)
@@ -144,13 +144,13 @@ func Benchmark(b *testing.B) {
b.Run("Delete", func(b *testing.B) {
b.Run("Naive", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
delete(testMap, strings.ToLower(key))
}
})
b.Run("NoCase", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
Delete(testMap, key)
}
})