diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-03-15 16:52:10 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-03-21 21:54:06 +0000 |
commit | 5ce2235f425b3c5047faf709c87c9b5c8e414b8b (patch) | |
tree | 5bd74cf139185d284a9379f095e31e0b8f1b6f36 /src/qml/qml/qqmltypeloader_p.h | |
parent | fc0254a48c775cdfea693402d0472b73c8b940e5 (diff) |
Avoid reading (not parsing) .qml files when using the cache
By making SourceCodeData copyable we can delay the reading of the source
file until we really need to. This also allows persisting the QFileInfo
object and therefore having only one stat() call to check if the file
exists, what its size is and what the last modification time is.
Change-Id: Ic7e4d5f566d870f3b1fa8302227417fa813cb139
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader_p.h')
-rw-r--r-- | src/qml/qml/qqmltypeloader_p.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index c1b3548fa6..0bae857874 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -54,6 +54,7 @@ #include <QtQml/qtqmlglobal.h> #include <QtCore/qobject.h> #include <QtCore/qatomic.h> +#include <QtCore/qfileinfo.h> #if QT_CONFIG(qml_network) #include <QtNetwork/qnetworkreply.h> #endif @@ -132,12 +133,14 @@ public: class SourceCodeData { public: - QString readAll(QString *error, qint64 *sourceTimeStamp = 0) const; + QString readAll(QString *error) const; + qint64 sourceTimeStamp() const; + bool exists() const; private: friend class QQmlDataBlob; friend class QQmlTypeLoader; - QString inlineSourceCodeOrFileName; - bool sourceCodeAvailable = false; + QString inlineSourceCode; + QFileInfo fileInfo; }; protected: @@ -460,8 +463,7 @@ private: void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override; - qint64 m_sourceTimeStamp = 0; - QString m_backupSourceCode; // used when cache verification fails. + SourceCodeData m_backupSourceCode; // used when cache verification fails. QScopedPointer<QmlIR::Document> m_document; QV4::CompiledData::TypeReferenceMap m_typeReferences; |