Re: Do I need to refactor this code?
- Posted by mattlewis (admin) Jul 03, 2013
- 1356 views
Does it make practical sense? I know that C++ compilers (at least some of them) are able to do this automatically. What about Euphoria? I use eushroud, if it is important.
If you have information that this is a real bottleneck, then it may make practical sense. While euphoria won't completely optimize out duplicate comparisons, it does do short circuiting, so if, in a long string of and operations, it find something false, it won't perform the rest of the operations. Likewise, if a true value is found in the first argument of an or operation, it won't bother with the second.
Most of your code doesn't need to be optimized, as a general rule. And due to short circuiting, it might be easier or more effective to reorder comparisons if you have some knowledge of the underlying data.
Matt