blend function urgently needed in kdelibs
Matthew Woehlke
mw_triad at users.sourceforge.net
Tue May 22 02:15:51 BST 2007
Robert Knight wrote:
>> ok... sizeof(KColor) == sizeof(void*), it has a d-ptr (it NEEDS a
>> d-ptr!). sizeof(KColorPrivate) == 80 at least; more if/when more color
>> spaces are supported.
>> So that's an overhead of at least 184 bytes.
>
> That doesn't make sense. You are taking 3 to 6 parameters, presumably
> no more than 8 bytes each and putting them into a class. Where does
> this > 180 figure come from?
>
> Regards,
> Robert.
First, you always need all six parameters worth of storage, so...
two KColors = ( 80 + 4 ) * 2 = 168
two doubles (k, r) = 8 * 2 = 16 + 168 = 184
Oh, and I forgot the space and flags... so it's 192 bytes not 184.
We could cut sizeof(KColorPrivate) to 44 bytes as per Matt Nowell's
suggestion but that's still 120 bytes. Or maybe use short instead of
double (bye bye possible HDR support, not that I *really* expect to need
it) and get down to more like 16 bytes per KColor. But then, we're not
even talking cache lines here; even a hundred KColor's is pretty cheap :-).
--
Matthew
When in doubt, duct tape!
More information about the kde-core-devel
mailing list