_(there are two things being discussed here: speed and coding style. This post
has to do with speed differences)_
I have simplified the benchmark I posted before.
The statement
> it's way slower than using explicit numerical bounds
seems VERY difficult to prove, given the following code:
import times, sequtils
const
LoopCnt = 50_000_000
var
t0 = epochTime()
ival = newSeqWith(LoopCnt, 0)
proc p1() =
t0 = epochTime()
for j in 0..LoopCnt-1: ival[j] += 1
echo "Dur (..) : ", 1_000_000*(epochTime() - t0)
proc p2() =
t0 = epochTime()
for j in 0..<LoopCnt: ival[j] += 1
echo "Dur (..<) : ", 1_000_000*(epochTime() - t0)
proc main() =
p1(); p2(); p2(); p1()
p1(); p2(); p2(); p1()
main()
which (looking at the c code) produces loops where the difference is the
following lines
if (!(res <= ((NI) 49999999))) goto LA3;
and
if (!(i < ((NI) 50000000))) goto LA3;
so the difference between testing `<=` and testing `<` can **NOT** produce
significant differences (and certainly does not account for a 2 second
difference).
(of course I am not testing array/sequences indexing, just loops)