-
- (*tp)->child[0]->state= -((*tp)->state>0);
- (*tp)->child[1]->state= (*tp)->state<0 ;
- (*tp)->state=0;
- }else{
- *tp= *child;
- *child= (*child)->child[i^1];
- (*tp)->child[i^1]= t;
- if((*tp)->state) t->state = 0;
- else t->state>>= 1;
- (*tp)->state= -t->state;
+ i= 4*t->state + 2*(*tp)->state + 12;
+ t ->state= ((0x614586 >> i) & 3)-1;
+ (*tp)->state= ((*tp)->state>>1) + ((0x400EEA >> i) & 3)-1;
+ }
+ but such a rotate function is both bigger and slower
+ */
+ if (( *child )->state * 2 == -t->state) {
+ *tp = (*child)->child[i ^ 1];
+ (*child)->child[i ^ 1] = (*tp)->child[i];
+ (*tp)->child[i] = *child;
+ *child = ( *tp )->child[i ^ 1];
+ (*tp)->child[i ^ 1] = t;
+
+ (*tp)->child[0]->state = -((*tp)->state > 0);
+ (*tp)->child[1]->state = (*tp)->state < 0;
+ (*tp)->state = 0;
+ } else {
+ *tp = *child;
+ *child = (*child)->child[i ^ 1];
+ (*tp)->child[i ^ 1] = t;
+ if ((*tp)->state) t->state = 0;
+ else t->state >>= 1;
+ (*tp)->state = -t->state;