A quick optimization question

Blitz3D Forums/Blitz3D Programming/A quick optimization question

Rogue Vector(Posted 2004) [#1]
Is this code:

g_update = 1 - g_update
Select g_update
Case 0 : ;Do nothing
Case 1 : Update()
End Select

faster than this code:

g_update = 1 - g_update
If (g_update=True) then Update()

Regards,

RV

www.OctaneDigitalStudios.com


Who was John Galt?(Posted 2004) [#2]
Erm... not sure on the ins and outs of the compiler... time it. If either is faster, it will be the second one.


Warren(Posted 2004) [#3]
If you can't tell, it doesn't matter.


bradford6(Posted 2004) [#4]
'select case' is slower than 'if then' because it contains 3 more letters and therefore will take you longer to type it in.


Bot Builder(Posted 2004) [#5]
:) the equals sign costs you a smidgen of time. do this:
g_update = 1 - g_update
If g_update then Update()



Techlord(Posted 2004) [#6]
I wrote a Scripting Language compiler and learned a lot about optimization. The less pushing, popping, and math operations, the better. As bot builder stated
g_update = 1 - g_update
If g_update Update()
is the better option.

But, i'm curious as to why you would want to cut the update in half this way. Is this some form of timing mechanism?


BlitzSupport(Posted 2004) [#7]
EpicBoy speaks the truth.