Author: Ratko V Tomic
Date: 19:57:50 11/18/02
Go up one level in this thread
>price of penalty is quite high. Your code of using pointers cannot improve
>anything about that.
Code using pointers can often make multiple decisions in a single indirect
jump, e.g. say (a) and (b) are boolean (0,1) types:
if (a)
{ Block_a1}
else
{ Block_a2}
if (b)
{ Block_b1}
else
{ Block_b2}
If (b) is computable at the time of evaluation of (a)
then you can make a single jump/call to one of the
4 labels/functions containing via value (a+2*b)
func_00: {Block_a1; Block_b1}
func_01: {Block_a1; Block_b2}
func_10: {Block_a2; Block_b1}
func_11: {Block_a2; Block_b2}
The same type of optimization can be done if the (b)-decision
is nested within (a)-decision. You pay in memory size, i.e.
to combine N decisions (nested or serial in any mix) into a
single jump/call you need 2^N block combinations.
For non-binary decisions, e.g. a loop of type:
for(i=0; i<n; ++i)
{LoopBlock;}
you can do a switch of the following type:
(where, say, you know that n<10)
switch(n)
{
case 9: {LoopBlock;}
case 8: {LoopBlock;}
...
case 1: {LoopBlock;}
}
(with no break between case labels).
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.