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>
bb10
David Faure 2015-07-27 00:22:11 +02:00
parent afaeecd4e8
commit 34130b9caf
2 changed files with 4 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
};
/*