On 10/17/11 4:18 PM, "ext Thiago Macieira" <[email protected]> wrote:
>On Monday, 17 de October de 2011 12:11:09 [email protected] wrote: >> Aren't we now making things way to complicated? > >Yes. > >> If we go for storing the hash in the string as well, we can't do it in >>16 >> bytes, so 24 is our next best option on 32bit systems. How about a >>simple >> >> struct Data { >> QRefCount ref; >> int alloc; >> uint32 flags; >> uint32 hash; >> int size; // or end, depending on what's more convenient >> qptrdiff begin; >> } >> >> This gives 24 bytes on 32bit systems, 32 on 64bit. The hash stays 0 for >> compile time strings. > >Right. On 64-bit systems, there's a 4-byte padding before "begin", but I >guess >that is intentional. Yep. That's why I ordered them this way :) > >> Another option we discussed earlier (at least for QString and QByteArray >> was to remove the fromRawData() functionality. In that case we could >> simply do: >[snip] > >I'd prefer the above option though. Your solution also removes the >prepend >optimisation. You can do the prepend optimization with the structure above. You can let begin point into the string data and have some space at the beginning. > >Even though QString("hi") has 4 bytes of payload and 24 (32) bytes of >overhead >-- 85.7% (88.8%). Yes, unfortunately. On the other hand is starts mattering less on "Hello World.", where overhead and payload start being equal. The question is whether saving 8 bytes here will really make a difference, or whether there are other places where we can save more in total. Cheers, Lars _______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
