Re: [cc65] Optimizing C code

Date view Thread view Subject view

From: Groepaz (groepaz_at_gmx.net)
Date: 2003-09-09 18:44:03


On Tuesday 09 September 2003 18:28, MagerValp wrote:
> >>>>> "SJ" == Shawn Jefferson <sjefferson_at_sd62.bc.ca> writes:
>
> SJ> if (creg != BAKCOL(bmp->mode)) {              // not background color?
> SJ>   //++creg;                                     // creg 0->01, 1->10,
> 2->11 SJ>   data |= ((creg+1) << plot4cshift[bit]);
> SJ> }
>
> Wouldn't it be faster to use a 4-byte table and just use
>
>   data |= creg << plot4cshift[bit];
>
> It'd save you an if and the addition, at the expense of a single byte.
> Also, the whole function could be written as a macro with global
> variables. Code size would increase a bit if it's called in a lot of
> places, but you'd get rid of the function call overhead (20%?).

also some line above..... replace "% 4" by "& 3" (not sure if the compiler is 
smart enough to do it for you)

gpz

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-09-09 18:48:22 CEST