QMimeType performance fix: don't reload from XML files over and over.
authorDavid Faure <faure@kde.org>
Wed, 2 May 2012 21:19:13 +0000 (23:19 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 7 May 2012 15:55:58 +0000 (17:55 +0200)
Change-Id: Ie19c338ed6449ea1509306cbda5dc251295783ae
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
src/corelib/mimetypes/qmimeprovider.cpp
src/corelib/mimetypes/qmimetype.cpp
src/corelib/mimetypes/qmimetype_p.h

index 0c2f25a..1f7d06c 100644 (file)
@@ -529,6 +529,9 @@ QList<QMimeType> QMimeBinaryProvider::allMimeTypes()
 
 void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
 {
+    if (data.loaded)
+        return;
+    data.loaded = true;
     // load comment and globPatterns
 
     const QString file = data.name + QLatin1String(".xml");
index 5ee70e8..3a3112f 100644 (file)
@@ -63,6 +63,7 @@ bool qt_isQMimeTypeDebuggingActivated (false);
 #endif
 
 QMimeTypePrivate::QMimeTypePrivate()
+    : loaded(false)
 {}
 
 QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other)
@@ -70,7 +71,8 @@ QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other)
         localeComments(other.d->localeComments),
         genericIconName(other.d->genericIconName),
         iconName(other.d->iconName),
-        globPatterns(other.d->globPatterns)
+        globPatterns(other.d->globPatterns),
+        loaded(other.d->loaded)
 {}
 
 void QMimeTypePrivate::clear()
@@ -80,6 +82,7 @@ void QMimeTypePrivate::clear()
     genericIconName.clear();
     iconName.clear();
     globPatterns.clear();
+    loaded = false;
 }
 
 /*!
index f2c7f96..775d527 100644 (file)
@@ -68,6 +68,7 @@ public:
     QString genericIconName;
     QString iconName;
     QStringList globPatterns;
+    bool loaded;
 };
 
 QT_END_NAMESPACE