Re: IF / WHILE / FOR

new topic     » goto parent     » topic index » view thread      » older message » newer message

Daniel Kluss wrote:
> I remember hearing a while ago about "while 1 do" being omptimized 
> somehow in euphoria, and was wondering if "if 1 then / if 0 then" or 
> even "for " are similarly optimized.
> I'm wondering if a bunch of "if <constant> then" 's can be done with no
> penalty in speed.

"while 1 do"
is optimized to nothing (no code) in the 
interpreter and translator (an infinite loop is set up 
that requires "exit" or "return" to get out). You'll be 
able to see this for yourself when I release the 
Euphoria in Euphoria source.

The other cases above aren't fully optimized.
I plan to optimize "if 0 then" and "if 1 then" 
by deleting all the code in the case that won't 
be executed. If you use the translator, there's
a good chance that the C compiler will do this
optimization anyway.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu