all: remove LenIter, use Go 1.22 range-over-int instead

Updates #11058
Updates golang/go#65685

Change-Id: Ibb216b346e511d486271ab3d84e4546c521e4e22
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-02-25 07:57:11 -08:00
committed by Brad Fitzpatrick
parent ff1391a97e
commit e1bd7488d0
18 changed files with 45 additions and 81 deletions
-15
View File
@@ -77,11 +77,6 @@ func (v ByteSlice[T]) AppendTo(dst T) T {
return append(dst, v.ж...)
}
// LenIter returns a slice the same length as the v.Len().
// The caller can then range over it to get the valid indexes.
// It does not allocate.
func (v ByteSlice[T]) LenIter() []struct{} { return make([]struct{}, len(v.ж)) }
// At returns the byte at index `i` of the slice.
func (v ByteSlice[T]) At(i int) byte { return v.ж[i] }
@@ -154,11 +149,6 @@ func (v SliceView[T, V]) IsNil() bool { return v.ж == nil }
// Len returns the length of the slice.
func (v SliceView[T, V]) Len() int { return len(v.ж) }
// LenIter returns a slice the same length as the v.Len().
// The caller can then range over it to get the valid indexes.
// It does not allocate.
func (v SliceView[T, V]) LenIter() []struct{} { return make([]struct{}, len(v.ж)) }
// At returns a View of the element at index `i` of the slice.
func (v SliceView[T, V]) At(i int) V { return v.ж[i].View() }
@@ -245,11 +235,6 @@ func (v Slice[T]) IsNil() bool { return v.ж == nil }
// Len returns the length of the slice.
func (v Slice[T]) Len() int { return len(v.ж) }
// LenIter returns a slice the same length as the v.Len().
// The caller can then range over it to get the valid indexes.
// It does not allocate.
func (v Slice[T]) LenIter() []struct{} { return make([]struct{}, len(v.ж)) }
// At returns the element at index `i` of the slice.
func (v Slice[T]) At(i int) T { return v.ж[i] }