Hi!
Which function is faster?
if / else / endif
or
select
::)
I hope I'm not totally wrong, but I mean that Select-Case can be optimized by the compiler to something like a branchtable. So I think Select Case will be faster then If-Then-Else.
thats also my opinion -> SELECT
Select can be optimisedin some special cases (it is its faster then if) - besides this special cases it should be the same speed like if. But you never exactly know what kind of optimisations your compiler does and what not.
But there is no guaranty that results would be the same on other machines, most times its not really useful to optimise for your own machine - you dont really know what will happen on your customers machines.
Select/case is (currently) always converted to groups of if statements. IF statements always adds a "if (false)" block to the C++ code as well for some reason. I have mentioned that to Gernot before as it's not needed and just wastes processor time.
Hi guys, I think the same.... C++ compiled SELECT are in theory more fast...
But, last comment of @MrTaToad have turned me crazy O_O
select are converted to a if / then?
:blink:
Yes our theory was one point - but MrT is right GLB does compile to if (with the unnecessary if (false)) that he mentioned. TY for pointing this out, I will avoid select for now.
Its always interesting to have a look at the generated code. ;)
Yes, certainly is. Whilst CPU cycles for the offending line would be small, it isn't really needed as it would never get executed!