On Not | Mo Chit

May 28, 2004

Flash: Short circuit evaluation After seeing Darron Schall's white space revelation the other day, I thought I would share something else common to most programming languages. In Actionscript logical expressions are evaluated executing the least amount of comparisons necessary to evaluate the expression. For example
if(true || complexFunction()) ...
if(false && complexFunction()) ...
In both examples complexFunction() will never be executed since it is unnecessary to evaluate the expression. So if your looking for that extra bit of performance, it's always good practice when forming potentially intensive logical comparisons, to put the least complicated comparisons first.

Creative Commons License
This site is licensed under a
Creative Commons License