Optimizations

General FreeBASIC programming questions.
TJF
Posts: 3503
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:
Assuming that I guessed right in my previous post, this may be your solution:
IF BIT(&b001001001001001001001001001001001001001001001, bx + by + bz) THEN

(For bx + by + bz <= 46. You may adapt it up to values of 63.)
Gonzo
Posts: 722
Joined: Dec 11, 2005 22:46
nicely done, i definitely didnt see any aliasing or excessive corridoring :)
the pattern makes trees look less volumptuos and saves a bit of processing!
Gonzo
Posts: 722
Joined: Dec 11, 2005 22:46
what exactly does andalso and orelse do?
i read that they were short-circuiting so i guess they're like an early exit in programming terms?
TJF
Posts: 3503
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:
This
IF a = b ANDALSO c = d THEN
is equal to
IF a = b THEN IF c = d THEN

The second expression (c = d) will only be checked if the first (a = b) does match.

Similar ORELSE: the second expression will only be checked if the first doesn't match.

You can speed up your code by puting time consuming computations (ie a function call) in the second expression.
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

When i added those operators, I based them on top of IIF. It's certainly possible to do it much better, but that was the only way I could find at the time that worked correctly, so I decided it was better to have the operators, working correctly, but not well optimized, than not have the operators at all.
fxm
Posts: 9528
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE