summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2015-07-27 00:22:11 +0200
committerDavid Faure <david.faure@kdab.com>2015-08-12 09:03:09 +0000
commit34130b9caf001682f1decb6ba69b80657b814ed0 (patch)
tree851cc37d45b236b9b4de1830dad6eacd6e78b2fd /src/corelib
parentafaeecd4e8adc5de3a94bbdbf7e6d805d66c4241 (diff)
QMimeDatabase: use QElapsedTimer instead of QDateTime::currentDateTime()
This reduces the number of syscalls greatly, by avoiding the timezone conversion every time. Change-Id: I39a54def4b45f25c6e037ced6943b05ddc749c9d Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp5
-rw-r--r--src/corelib/mimetypes/qmimeprovider_p.h3
2 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index 7342a5cd77..1ab1a44392 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -79,10 +79,9 @@ Q_CORE_EXPORT int qmime_secondsBetweenChecks = 5; // exported for the unit test
bool QMimeProviderBase::shouldCheck()
{
- const QDateTime now = QDateTime::currentDateTime();
- if (m_lastCheck.isValid() && m_lastCheck.secsTo(now) < qmime_secondsBetweenChecks)
+ if (m_lastCheck.isValid() && m_lastCheck.elapsed() < qmime_secondsBetweenChecks * 1000)
return false;
- m_lastCheck = now;
+ m_lastCheck.start();
return true;
}
diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h
index 5a89ac23c3..eaf95942f7 100644
--- a/src/corelib/mimetypes/qmimeprovider_p.h
+++ b/src/corelib/mimetypes/qmimeprovider_p.h
@@ -51,6 +51,7 @@
#include <QtCore/qdatetime.h>
#include <QtCore/qset.h>
+#include <QtCore/qelapsedtimer.h>
QT_BEGIN_NAMESPACE
@@ -77,7 +78,7 @@ public:
QMimeDatabasePrivate *m_db;
protected:
bool shouldCheck();
- QDateTime m_lastCheck;
+ QElapsedTimer m_lastCheck;
};
/*