From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-09-04 11:10:23
Hi! On Wed, Sep 03, 2003 at 12:57:12PM -0700, Shawn Jefferson wrote: > I have a routine that plots pixels on a memory bitmap and am making an > attempt to optimize it. I'm hoping some of you C wizards can help. Some changes have already been suggested, here is more: 1. Don't use var++, use ++var instead (I don't know how often I have written this, it really gets boring...). 2. Make the x and y parameters unsigned. 3. byte is not needed: index = BYTES_PER_LINE(bmp) * y + x / 4; 4. mask is not really needed: if (creg != BAKCOL(bmp->mode)) { data |= (creg+1) << plot4cshift[bit]; } 5. In fact, it is also possible to remove the data variable. 6. The multiplication will kill your performance, so I would try to work around it. 7. Calling a subroutine for each pixel passing 4 parameters over the stack is a performance problem for itself. I would suggest to use nested loops instead that plot whole rows or the complete picture. Doing this, it would also be possible to eliminate the multiplication (except for the start). 1. and 2. are mentioned explicitly in the docs (coding.xxxx), you may want to (re-)read this document. In general, it is a good idea to look at the generated assembler code. Doing this, it is easy to spot areas where the compiler generated code is a problem. Regards Uz -- Ullrich von Bassewitz uz_at_musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2003-09-04 11:10:32 CEST