diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-10-23 16:32:59 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-10-23 18:09:18 +0000 |
commit | 2cdafb099945bd534f0c752edf8d4f1ab80ed45f (patch) | |
tree | a17e7cc311a804d920cd5f1054c6870eab6a9fae /src/corelib/plugin/quuid.cpp | |
parent | 8a8a5813a9fcbaef4dd96e8c33f605043d51b590 (diff) |
Convert some QDateTime::currentDateTime() to currentDateTimeUtc() (I)
The latter is much faster as it doesn't have to deal with
time zones.
This change handles the trivial ones: Either the call to
currentDateTime() is immediately followed by a call to toUTC()
or toTime_t(). The latter is much faster on UTC QDateTimes, too.
Credits to Milian Wolff, from whose QtWS15 talk this advice is
taken.
Change-Id: I872f5bbb26cbecedc1e5c0dbee4d5ac2c6eb67ee
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src/corelib/plugin/quuid.cpp')
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 6698b140af..0e1557941d 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -963,7 +963,7 @@ QUuid QUuid::createUuid() { int *pseed = new int; static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); - qsrand(*pseed = QDateTime::currentDateTime().toTime_t() + qsrand(*pseed = QDateTime::currentDateTimeUtc().toTime_t() + quintptr(&pseed) + serial.fetchAndAddRelaxed(1)); uuidseed.setLocalData(pseed); @@ -971,7 +971,7 @@ QUuid QUuid::createUuid() #else static bool seeded = false; if (!seeded) - qsrand(QDateTime::currentDateTime().toTime_t() + qsrand(QDateTime::currentDateTimeUtc().toTime_t() + quintptr(&seeded)); #endif |