[Development] Notes from the Containers session from QtCS

André Pönitz andre.poenitz at mathematik.tu-chemnitz.de
Sun Jun 24 22:13:58 CEST 2012


On Sun, Jun 24, 2012 at 09:08:45PM +0200, Thiago Macieira wrote:
> André suggested a container main class as: class QString { ushort *data;
> int size; int d_offset; };
> 
> so that d = reinterpret_cast<char *>(data) + d_offset.
> 
> That class has 16 bytes in size. However, it breaks for fromRawData,
> since the heap and mmap'ed areas might be more than 2^31 apart. In fact,
> on Linux 64- bit, they'll be in the order of 2^46 apart.

For some reason I forgot to mention that with the current guarantee for
fromRawData usage (user has to make sure that the base data will not be
deleted or modified as long as the QString (or an unmodified copy of it)
exists) this does not require d 'data' at all, just another 'magic'
d_offset value to identify the situation. Reference counting is not
needed, as the string (and copies thereof) have been guaranteed to die
before the base data goes away.

However, since there's no chance to cross the pass-on-stack vs pass-in
-registers boundary, and we might face extra work if we go further down
the cheap substrings (on-potentially-fromRawData-strings...) road I
concede that pursuing that direction is not worthwhile, and having
always enough space to store a full d pointer opens up the possibility
to e.g. pass custom deleters around in such cases, i.e. make (more)
fromRawData strings first class citizens.

Andre'



More information about the Development mailing list