Hi,
I am trying out v0.20. Thanks for all the work!
I recompiled some CPU intensive code I wrote and was surprised to find out that
running time trebled on typical input. Poking around, I found that the
generated C code shows array range checks:
/* with 'nimble build -d:release */
if ((NU)(i) >= (NU)((*data).itemNodes ? (*data).itemNodes->Sup.len
: 0)) raiseIndexError2(i,((*data).itemNodes ? (*data).itemNodes->Sup.len :
0)-1);
l = (*data).itemNodes->data[i].llink;
if ((NU)(i) >= (NU)((*data).itemNodes ? (*data).itemNodes->Sup.len
: 0)) raiseIndexError2(i,((*data).itemNodes ? (*data).itemNodes->Sup.len :
0)-1);
r = (*data).itemNodes->data[i].rlink;
Run
When I disable runtime checks explicitly the range checks disappear, as
expected, and my running times return to what they were before.
/* with `nimble build -d:release --checks:off */
l = (*data).itemNodes->data[i].llink;
r = (*data).itemNodes->data[i].rlink;
Run
The compiler manual at
[https://nim-lang.org/docs/nimc.html](https://nim-lang.org/docs/nimc.html) says
that the `release` switch "[t]urns off runtime checks and turns on the
optimizer." It worked that way for me in the 0.19 series.
Am I seeing this behavior because I use nimble to build and not "nim c"?