A quick optimization question
Blitz3D Forums/Blitz3D Programming/A quick optimization question
| ||
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 |
| ||
Erm... not sure on the ins and outs of the compiler... time it. If either is faster, it will be the second one. |
| ||
If you can't tell, it doesn't matter. |
| ||
'select case' is slower than 'if then' because it contains 3 more letters and therefore will take you longer to type it in. |
| ||
:) the equals sign costs you a smidgen of time. do this:g_update = 1 - g_update If g_update then Update() |
| ||
I wrote a Scripting Language compiler and learned a lot about optimization. The less pushing, popping, and math operations, the better. As bot builder statedg_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? |
| ||
EpicBoy speaks the truth. |