Skip to content

Commit 75f1392

Browse files
committed
refactor: use golang 1.23 numeric range for loop
1 parent 896ac5a commit 75f1392

File tree

1 file changed

+3
-3
lines changed
  • language/orion/starlark/utils

1 file changed

+3
-3
lines changed

language/orion/starlark/utils/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func ReadList[V any](v starlark.Value, f func(v starlark.Value) V) []V {
7676
l := v.(*starlark.List)
7777
len := l.Len()
7878
a := make([]V, 0, len)
79-
for i := 0; i < len; i++ {
79+
for i := range len {
8080
a = append(a, f(l.Index(i)))
8181
}
8282
return a
@@ -85,7 +85,7 @@ func ReadList[V any](v starlark.Value, f func(v starlark.Value) V) []V {
8585
func ReadTuple[V any](t starlark.Tuple, f func(v starlark.Value) V) []V {
8686
len := t.Len()
8787
a := make([]V, 0, len)
88-
for i := 0; i < len; i++ {
88+
for i := range len {
8989
a = append(a, f(t.Index(i)))
9090
}
9191
return a
@@ -148,7 +148,7 @@ func readIterable(v starlark.Iterable, len int, read func(v starlark.Value) inte
148148
func readIndexable(v starlark.Indexable, read func(v starlark.Value) interface{}) []interface{} {
149149
len := v.Len()
150150
a := make([]interface{}, 0, len)
151-
for i := 0; i < len; i++ {
151+
for i := range len {
152152
a = append(a, read(v.Index(i)))
153153
}
154154
return a

0 commit comments

Comments
 (0)