I was doing something which was pushing the boundaries the other day and had to do some serious optimisation.
I found that the following drastically improved large loop repetition (e.g. screen buffer updates.
A typical bounds check of:
if (x>0) and (x<XRES) and (y>0) and (y<YRES) then ..is commonly used. In some languages, the if statement will terminate when the first false condition is hit (providing the statement is fully parsed and the condition is determined to fail).
We normally don't have to worry about wasting CPU on pointless checking of the other conditions.
In FB however, it appears that all tests are evaluated - regardless of a single condition failure means the result will always be false, therefore:
if x>0 then
if x<XRES then
if y>0 then
if y<YRES then .....
endif
endif
endif
endif
Will offer a significant reward in processing time. Obviously, sort the checks into the "most likely order of occurance" to abort the test at the earliest opportunity.
I found that this made some huge speed improvements!



