Remove outdated comment and copy of length (#14759)
This commit is contained in:
parent
59ba4d8c03
commit
03c8bbcc6e
1 changed files with 3 additions and 13 deletions
|
|
@ -1,21 +1,12 @@
|
||||||
when defined(nimHasLentIterators) and not defined(nimWorkaround14447):
|
when defined(nimHasLentIterators) and not defined(nimWorkaround14447):
|
||||||
template lent2(T): untyped =
|
template lent2(T): untyped = lent T
|
||||||
# xxx this should actually depend on T.sizeof >= thresLentSizeof
|
|
||||||
# with for example `thresLentSizeof ~= int.sizeof`:
|
|
||||||
# it may be faster to return by value for small sizes compared to
|
|
||||||
# forcing a deref; this could be adjusted using profiling.
|
|
||||||
# However, `simply using `when T.sizeof >= thresLentSizeof: lent T else: T`
|
|
||||||
# does not work, for a few reasons (eg importc types would cause CT error
|
|
||||||
# and we can't filter them out without compiles() or some magic.
|
|
||||||
lent T
|
|
||||||
else:
|
else:
|
||||||
template lent2(T): untyped = T
|
template lent2(T): untyped = T
|
||||||
|
|
||||||
iterator items*[T: not char](a: openArray[T]): lent2 T {.inline.} =
|
iterator items*[T: not char](a: openArray[T]): lent2 T {.inline.} =
|
||||||
## Iterates over each item of `a`.
|
## Iterates over each item of `a`.
|
||||||
var i = 0
|
var i = 0
|
||||||
let n = len(a)
|
while i < len(a):
|
||||||
while i < n:
|
|
||||||
yield a[i]
|
yield a[i]
|
||||||
inc(i)
|
inc(i)
|
||||||
|
|
||||||
|
|
@ -25,8 +16,7 @@ iterator items*[T: char](a: openArray[T]): T {.inline.} =
|
||||||
# elements converted from a string (would fail in `tests/misc/thallo.nim`)
|
# elements converted from a string (would fail in `tests/misc/thallo.nim`)
|
||||||
# in any case there's no performance advantage of returning char by address.
|
# in any case there's no performance advantage of returning char by address.
|
||||||
var i = 0
|
var i = 0
|
||||||
let n = len(a)
|
while i < len(a):
|
||||||
while i < n:
|
|
||||||
yield a[i]
|
yield a[i]
|
||||||
inc(i)
|
inc(i)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue