[Development] Proposal: adding Q_DECL_NOEXCEPT to many methods
konrad at silmor.de
Thu Aug 2 17:55:54 CEST 2012
On Thursday 02 August 2012 15:27:03 Thiago Macieira wrote:
> For example, in when I was just now adding it to qHash for QDateTime, I
> realised it does complex operations. Right now, none of those operations
> allocate memory, but it's actually very close to doing that. QDateTime has
> a d pointer and the hash function does some manipulation of the data. If I
> add it now, it means it cannot allocate memory, ever, in Qt 5. For that
> reason, I'm not sure I can do it: what if the implementation for QDateTime
> when timezones are taken into account needs to new?
Where is qHash(QDateTime) defined? It doesn't seem to be where I expected it
(qhash.* or qdatetime.*).
Anyway, Timezones can do rather complex calculations that may require memory-
allocations, but only when the QDateTime actually does calculations:
* add or subtract some time to/from the QDateTime (addSecs, addMSecs)
* convert to a different time zone (toUtc, toLocalTime, toTimeZone(x))
* convert to or from time_t
Any of those operations needs a search of the time zone for the offset valid
at the time to be converted, if we are lucky the offset is already in memory,
if not we need to retrieve it from a file, or worse to calculate it from a
POSIX-style rule (and then cache it for later). When converting to another
zone things get worse.
Depending on the implementation that will end up in Qt the actual lookup for
which time zone is being used may have side effects too.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/development/attachments/20120802/7cefc73f/attachment.bin
More information about the Development