[Development] Short QDateTime optimisation

Thiago Macieira thiago.macieira at intel.com
Mon May 2 04:35:19 CEST 2016



I've just pushed one large commit that changes QDateTime to support a "short 
QDateTime Optimisation". Inspired by the SSO mechanism used in libc++ and 
similar to what we've done to QVersionNumber, I've made QDateTime not allocate 
memory for most uses (local time or UTC, within 2 million years of 1970).

The optimisation is only for 64-bit systems, since QDateTime simply wasn't 
wide enough to accommodate the data. 32 bits isn't enough for storing seconds 
since 1970, much less milliseconds and the extra information we needed. But on 
64-bit systems, the pointer is split in two: 8 bits for status flags (including 
the LSB indicating it's a short QDateTime) and 56 bits for the millisecond 

The commit is quite large. I will spend some time during the next week seeing 
if I can split it up into bite-sized chunks.

Meanwhile, I'd like to ask for help testing this. Since I've dropped the use 
of QSharedDataPointer, I might have introduced sharing issues. And I'd really 
like someone to run the unit tests on a big-endian system.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Development mailing list