[PATCH 14/18] xfixes: switch to byte counting functions

Peter Hutterer peter.hutterer at who-t.net
Fri Jul 10 04:10:27 PDT 2009


On Fri, Jul 10, 2009 at 11:33:59AM +0100, Bill Crawford wrote:
> Peter Hutterer wrote:
>
>> -    nbytesRound = (nbytes + 3) & ~3;
>> +    nbytesRound = pad_to_dwords(nbytes);
>
> You're replacing two arithmetic operations with a function call here,  
> and then ...
>
>> -    rep->length = npixels + (nbytesRound >> 2);
>> +    rep->length = npixels + num_dwords_for_bytes(nbytesRound);
>
> Is it really worth replacing a two-bit shift with a function call?

yes, IMO. 
- functions for common operations reduce the chance of bugs in those
  operations.
- readability. I claim that having a meaningful name for a common operation
  is easier to read.

note that the instances replaced (most of them, anyway) are protocol
handling - doubtfully the most performance-critical part.

Cheers,
  Peter


More information about the xorg-devel mailing list