> Hi
> 
> Working on my ViRGE driver, I noticed something:
> 
> Handling the KGI commands, most drivers use a switch () {case ...}
> structure. This looks nice, but results in very slow code (each case
> results in at least one conditional jump, which can slow down the CPU
> badly)
> 
> I was wondering: Using a procedure lookup table would improve the speed a
> lot, but would require that I can take the definitions in kgi_commands.h
> as static ones. It would result in code like (this is no real code, 
> only to make things clear)
> 
> int * accelleration_command[](void *, struct kgi_display)= {
>   ViRGE_2D_DrawLine, /* This depends on kgi_commands.h */
>   ViRGE_2D_DrawBox,
>   ... etc...
> }
> 
> (*accelleration_command[_IOC_NR(cmd)])(gr->io_buf,gr->dev.dpy);
> 
> instead of :
> switch (cmd) {
>   case ACCEL_DRAW_LINE:
>   case ....
>   case ....
> }
> 
> Notes here: _IOC_NR is Linux only and must be replaced by a KGI defined
> compatible function. I use _IOC_NR to get values in the range 0-255,
> otherwise the table would become very huge with many unused entries.
> 
> Comments please...
> 
> Jos

AFAIK GNU C does that if it becomes faster. So, it depends on the compiler
you use :-)

                        Steffen

----------------- e-mail: [EMAIL PROTECTED] -----------------

Reply via email to