items, pairs and friends now use unCheckedInc (#22729)

`{.push overflowChecks: off.}` works in backends. Though it could be
implemented as a magic function.

By inspecting the generated C code, the overflow check is eliminated in
the debug or release mode.

![image](https://github.com/nim-lang/Nim/assets/43030857/49c3dbf4-675e-414a-b972-b91cf218c9f8)

Likewise, the index checking is probably not needed.

(cherry picked from commit d82bc0a29f)
This commit is contained in:
ringabout
2023-09-20 18:50:23 +08:00
committed by narimiran
parent e918a762f7
commit 577ffbc57c
2 changed files with 35 additions and 26 deletions

View File

@@ -91,7 +91,9 @@ try:
`=copy`(lan_ip, splitted[1])
echo [lan_ip]
echo [splitted[1]]
{.push, overflowChecks: false.}
inc(i, 1)
{.pop.}
finally:
`=destroy`(splitted)
finally:
@@ -113,7 +115,9 @@ block :tmp:
addInterfaceDecl(c):
:tmpD = `=dup`(sym)
:tmpD
{.push, overflowChecks: false.}
inc(i, 1)
{.pop.}
`=destroy`(shadowScope)
-- end of expandArc ------------------------
--expandArc: check