- #1
ChrisVer
Gold Member
- 3,378
- 465
I've come across a rumor that states that if-else statements can make the loops go slower. Well, it's not rumors since the writer offered numbers (times) to support the statement.
http://blogs.sas.com/content/iml/2012/02/13/avoid-unnecessary-if-then-statements-in-loops.html
I was wondering though: it says "For some compiled programming languages such as FORTRAN and C/C++, an optimizing compiler can sometimes determine that an expression is constant and move it outside of the loop for you."
What does "sometimes determine that an expression is constant" and can you know it beforehand?
Thanks
http://blogs.sas.com/content/iml/2012/02/13/avoid-unnecessary-if-then-statements-in-loops.html
I was wondering though: it says "For some compiled programming languages such as FORTRAN and C/C++, an optimizing compiler can sometimes determine that an expression is constant and move it outside of the loop for you."
What does "sometimes determine that an expression is constant" and can you know it beforehand?
Thanks