Re: Match Question
- Posted by Michael J. Sabal <m_sabal at yahoo.com> Jan 17, 2007
- 510 views
don cole wrote: > > Hello Everybody, > > Suppose the code: > > }}} <eucode> > if match(q,"A") or match(q,"B") or match(q,"C") or match(q,"D") then > </eucode> {{{ > And you hit on a "B", would Euphoria continue looking or would that be the > end of it? > > If so, wouldn't be best to put the most likely scenario in the "A" > position? > > Don Cole This is a shortcutting feature that was introduced some years ago. You are correct that if B is a hit, the whole expression is true, so the interpreter won't bother evaluating anything else after that. The same thing happens with false conditions in a series of "and" expressions. If you are reasonably sure that "A" will happen say 40%, "B" 30%, "C" 20%, and "D" 10% (for example), then putting "A" first will definitely improve the overall performance of your program. Of course, YMMV depending on how often the conditions are checked and how complicated the match expressions are. Mike Sabal