Skip to content

Commit

Permalink
items(array)+friends: remove a RT comparison (#17650)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored Apr 6, 2021
1 parent 28de32c commit aa4f18e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/system/iterators.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ iterator mitems*[T](a: var openArray[T]): var T {.inline.} =

iterator items*[IX, T](a: array[IX, T]): T {.inline.} =
## Iterates over each item of `a`.
var i = low(IX)
if i <= high(IX):
when a.len > 0:
var i = low(IX)
while true:
yield a[i]
if i >= high(IX): break
inc(i)

iterator mitems*[IX, T](a: var array[IX, T]): var T {.inline.} =
## Iterates over each item of `a` so that you can modify the yielded value.
var i = low(IX)
if i <= high(IX):
when a.len > 0:
var i = low(IX)
while true:
yield a[i]
if i >= high(IX): break
Expand Down Expand Up @@ -146,8 +146,8 @@ iterator mpairs*[T](a: var openArray[T]): tuple[key: int, val: var T]{.inline.}

iterator pairs*[IX, T](a: array[IX, T]): tuple[key: IX, val: T] {.inline.} =
## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
var i = low(IX)
if i <= high(IX):
when a.len > 0:
var i = low(IX)
while true:
yield (i, a[i])
if i >= high(IX): break
Expand All @@ -156,8 +156,8 @@ iterator pairs*[IX, T](a: array[IX, T]): tuple[key: IX, val: T] {.inline.} =
iterator mpairs*[IX, T](a: var array[IX, T]): tuple[key: IX, val: var T] {.inline.} =
## Iterates over each item of `a`. Yields `(index, a[index])` pairs.
## `a[index]` can be modified.
var i = low(IX)
if i <= high(IX):
when a.len > 0:
var i = low(IX)
while true:
yield (i, a[i])
if i >= high(IX): break
Expand Down

0 comments on commit aa4f18e

Please sign in to comment.