Fastest Technique? 'elseif' or 'or'
Blitz3D Forums/Blitz3D Programming/Fastest Technique? 'elseif' or 'or'| 
 | ||
| Hey What is faster between those 2 expressions: this: if a=1 then ... elseif b=1 then ... elseif c=1 then ... end if or this: if a=1 or b=1 or c=1 then ... end if ? | 
| 
 | ||
| I wouldn't be too concerned about optimising this kind of thing.  The difference is negligible and would not be a bottleneck in your code. That said, you would have to evaluate between 1 and 3 pieces of logic in the first example, whereas the second would always be 3. So, logically the first would be faster in most cases. Stevie | 
| 
 | ||
| aaaaah ok gotcha !! thanks ^^ | 
| 
 | ||
| Continuing what Stevie says, you should first most make your code as easy to understand as possible. Optimising these things might sacrifice how easy it is to read or add/change your code. | 
| 
 | ||
| ALso they do not do the same thing. if a=1 then ... Run this when a=1 elseif b=1 then ... Run this when a<>1 AND B=1 elseif c=1 then ... Run this when A<>1 AND B<>1 AND c=1 end if if a=1 or b=1 or c=1 then ... Run this when A=1 or B=1 or C=1 end if SO my answer would be use the one you need | 
| 
 | ||
| I can't agree more your remark; I abandoned so many projects due to uneasy readable codes... But now, I think I got it, everything is well organized and in some cases the use of 'elseif' make it even more readable, so that's kool! My current program is around 7000 lines and I can find what I am looking for real fast. ^^ | 
| 
 | ||
| I'm finding the biggest slowdown in my project is linepicks and the collision system... |