diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2016-11-01 10:00:31 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2016-11-10 09:30:19 +0000 |
commit | a96116df6e01e131867f406695300959c9872527 (patch) | |
tree | 86997be854fff5f078f1d4f5cb82ae7b53e074bd /src | |
parent | 03a0a3d9fe95aec346b0934ec685e97fb4827c31 (diff) |
Use string sharing when serializing file tags
On my machine, the on-disk build graph of a freshly resolved Qt Creator
super project goes down by 12% with this patch.
Change-Id: Ic86b4ba31769d7d4af407b24a0ee9845cf943a79
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/corelib/buildgraph/artifact.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/productbuilddata.cpp | 5 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rescuableartifactdata.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/language/artifactproperties.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/language/filetags.cpp | 34 | ||||
-rw-r--r-- | src/lib/corelib/language/filetags.h | 6 | ||||
-rw-r--r-- | src/lib/corelib/language/language.cpp | 82 | ||||
-rw-r--r-- | src/lib/corelib/tools/persistence.cpp | 2 |
8 files changed, 61 insertions, 80 deletions
diff --git a/src/lib/corelib/buildgraph/artifact.cpp b/src/lib/corelib/buildgraph/artifact.cpp index 04a8c97c8..a00d7b623 100644 --- a/src/lib/corelib/buildgraph/artifact.cpp +++ b/src/lib/corelib/buildgraph/artifact.cpp @@ -158,9 +158,9 @@ void Artifact::load(PersistentPool &pool) pool.loadContainer(fileDependencies); properties = pool.idLoadS<PropertyMapInternal>(); transformer = pool.idLoadS<Transformer>(); + m_fileTags.load(pool); unsigned char c; pool.stream() - >> m_fileTags >> artifactType >> c; alwaysUpdated = c; @@ -178,8 +178,8 @@ void Artifact::store(PersistentPool &pool) const pool.storeContainer(fileDependencies); pool.store(properties); pool.store(transformer); + m_fileTags.store(pool); pool.stream() - << m_fileTags << artifactType << static_cast<unsigned char>(alwaysUpdated) << static_cast<unsigned char>(oldDataPossiblyPresent); diff --git a/src/lib/corelib/buildgraph/productbuilddata.cpp b/src/lib/corelib/buildgraph/productbuilddata.cpp index d67f667d1..7bd88e577 100644 --- a/src/lib/corelib/buildgraph/productbuilddata.cpp +++ b/src/lib/corelib/buildgraph/productbuilddata.cpp @@ -66,8 +66,7 @@ static void loadArtifactSetByFileTag(PersistentPool &pool, int elemCount; pool.stream() >> elemCount; for (int i = 0; i < elemCount; ++i) { - QVariant fileTag; - pool.stream() >> fileTag; + const QVariant fileTag = pool.loadVariant(); ArtifactSet artifacts; pool.loadContainer(artifacts); s.insert(FileTag::fromSetting(fileTag), artifacts); @@ -104,7 +103,7 @@ static void storeArtifactSetByFileTag(PersistentPool &pool, pool.stream() << s.count(); ProductBuildData::ArtifactSetByFileTag::ConstIterator it; for (it = s.constBegin(); it != s.constEnd(); ++it) { - pool.stream() << it.key().toSetting(); + pool.store(it.key().toSetting()); pool.storeContainer(it.value()); } } diff --git a/src/lib/corelib/buildgraph/rescuableartifactdata.cpp b/src/lib/corelib/buildgraph/rescuableartifactdata.cpp index 65af1b176..02c3d9ea6 100644 --- a/src/lib/corelib/buildgraph/rescuableartifactdata.cpp +++ b/src/lib/corelib/buildgraph/rescuableartifactdata.cpp @@ -69,7 +69,7 @@ void RescuableArtifactData::load(PersistentPool &pool) propertiesRequestedInCommands = restorePropertySet(pool); propertiesRequestedFromArtifactInPrepareScript = restorePropertyHash(pool); commands = loadCommandList(pool); - pool.stream() >> fileTags; + fileTags.load(pool); properties = pool.loadVariantMap(); } @@ -89,7 +89,7 @@ void RescuableArtifactData::store(PersistentPool &pool) const storePropertySet(pool, propertiesRequestedInCommands); storePropertyHash(pool, propertiesRequestedFromArtifactInPrepareScript); storeCommandList(commands, pool); - pool.stream() << fileTags; + fileTags.store(pool); pool.store(properties); } diff --git a/src/lib/corelib/language/artifactproperties.cpp b/src/lib/corelib/language/artifactproperties.cpp index 6b4bcd00f..eae9fb667 100644 --- a/src/lib/corelib/language/artifactproperties.cpp +++ b/src/lib/corelib/language/artifactproperties.cpp @@ -55,13 +55,13 @@ ArtifactProperties::ArtifactProperties() void ArtifactProperties::load(PersistentPool &pool) { - pool.stream() >> m_fileTagsFilter; + m_fileTagsFilter.load(pool); m_propertyMap = pool.idLoadS<PropertyMapInternal>(); } void ArtifactProperties::store(PersistentPool &pool) const { - pool.stream() << m_fileTagsFilter; + m_fileTagsFilter.store(pool); pool.store(m_propertyMap); } diff --git a/src/lib/corelib/language/filetags.cpp b/src/lib/corelib/language/filetags.cpp index 47b6274a5..c451a24b5 100644 --- a/src/lib/corelib/language/filetags.cpp +++ b/src/lib/corelib/language/filetags.cpp @@ -40,6 +40,8 @@ #include "filetags.h" #include <QStringList> +#include <tools/persistence.h> + namespace qbs { namespace Internal { @@ -75,6 +77,16 @@ bool FileTags::matches(const FileTags &other) const return false; } +void FileTags::store(PersistentPool &pool) const +{ + pool.storeStringList(toStringList()); +} + +void FileTags::load(PersistentPool &pool) +{ + *this = fromStringList(pool.idLoadStringList()); +} + LogWriter operator <<(LogWriter w, const FileTags &tags) { bool firstLoop = true; @@ -90,27 +102,5 @@ LogWriter operator <<(LogWriter w, const FileTags &tags) return w; } -QDataStream &operator >>(QDataStream &s, FileTags &tags) -{ - int i; - s >> i; - tags.clear(); - tags.reserve(i); - QVariant v; - while (--i >= 0) { - s >> v; - tags += FileTag::fromSetting(v); - } - return s; -} - -QDataStream &operator <<(QDataStream &s, const FileTags &tags) -{ - s << tags.count(); - foreach (const FileTag &ft, tags) - s << ft.toSetting(); - return s; -} - } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/language/filetags.h b/src/lib/corelib/language/filetags.h index 8c50d33f1..63e92e44d 100644 --- a/src/lib/corelib/language/filetags.h +++ b/src/lib/corelib/language/filetags.h @@ -47,6 +47,7 @@ namespace qbs { namespace Internal { +class PersistentPool; class FileTag : public Id { @@ -76,11 +77,12 @@ public: QStringList toStringList() const; static FileTags fromStringList(const QStringList &strings); bool matches(const FileTags &other) const; + + void store(PersistentPool &pool) const; + void load(PersistentPool &pool); }; LogWriter operator <<(LogWriter w, const FileTags &tags); -QDataStream &operator >>(QDataStream &s, FileTags & tags); -QDataStream &operator <<(QDataStream &s, const FileTags &tags); } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index 47099a0f0..86a8cce5d 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -104,7 +104,7 @@ void FileTagger::setPatterns(const QStringList &patterns) void FileTagger::load(PersistentPool &pool) { setPatterns(pool.idLoadStringList()); - pool.stream() >> m_fileTags; + m_fileTags.load(pool); } void FileTagger::store(PersistentPool &pool) const @@ -113,7 +113,7 @@ void FileTagger::store(PersistentPool &pool) const foreach (const QRegExp ®Exp, m_patterns) patterns << regExp.pattern(); pool.storeStringList(patterns); - pool.stream() << m_fileTags; + m_fileTags.store(pool); } @@ -148,7 +148,7 @@ void Probe::store(PersistentPool &pool) const void SourceArtifactInternal::load(PersistentPool &pool) { absoluteFilePath = pool.idLoadString(); - pool.stream() >> fileTags; + fileTags.load(pool); pool.stream() >> overrideFileTags; properties = pool.idLoadS<PropertyMapInternal>(); } @@ -156,7 +156,7 @@ void SourceArtifactInternal::load(PersistentPool &pool) void SourceArtifactInternal::store(PersistentPool &pool) const { pool.storeString(absoluteFilePath); - pool.stream() << fileTags; + fileTags.store(pool); pool.stream() << overrideFileTags; pool.store(properties); } @@ -216,9 +216,8 @@ void ResolvedGroup::load(PersistentPool &pool) pool.loadContainerS(files); wildcards = pool.idLoadS<SourceWildCards>(); properties = pool.idLoadS<PropertyMapInternal>(); - pool.stream() - >> fileTags - >> overrideTags; + fileTags.load(pool); + pool.stream() >> overrideTags; } void ResolvedGroup::store(PersistentPool &pool) const @@ -230,9 +229,8 @@ void ResolvedGroup::store(PersistentPool &pool) const pool.storeContainer(files); pool.store(wildcards); pool.store(properties); - pool.stream() - << fileTags - << overrideTags; + fileTags.store(pool); + pool.stream() << overrideTags; } /*! @@ -246,10 +244,9 @@ void ResolvedGroup::store(PersistentPool &pool) const */ void RuleArtifact::load(PersistentPool &pool) { - pool.stream() - >> filePath - >> fileTags - >> alwaysUpdated; + filePath = pool.idLoadString(); + fileTags.load(pool); + pool.stream() >> alwaysUpdated; location.load(pool); filePathLocation.load(pool); @@ -268,10 +265,9 @@ void RuleArtifact::load(PersistentPool &pool) void RuleArtifact::store(PersistentPool &pool) const { - pool.stream() - << filePath - << fileTags - << alwaysUpdated; + pool.storeString(filePath); + fileTags.store(pool); + pool.stream() << alwaysUpdated; location.store(pool); filePathLocation.store(pool); @@ -413,16 +409,13 @@ void Rule::load(PersistentPool &pool) prepareScript = pool.idLoadS<ScriptFunction>(); outputArtifactsScript = pool.idLoadS<ScriptFunction>(); module = pool.idLoadS<ResolvedModule>(); - pool.stream() - >> inputs - >> outputFileTags - >> auxiliaryInputs - >> excludedAuxiliaryInputs - >> inputsFromDependencies - >> explicitlyDependsOn - >> multiplex - >> alwaysRun; - + inputs.load(pool); + outputFileTags.load(pool); + auxiliaryInputs.load(pool); + excludedAuxiliaryInputs.load(pool); + inputsFromDependencies.load(pool); + explicitlyDependsOn.load(pool); + pool.stream() >> multiplex >> alwaysRun; pool.loadContainerS(artifacts); } @@ -432,16 +425,13 @@ void Rule::store(PersistentPool &pool) const pool.store(prepareScript); pool.store(outputArtifactsScript); pool.store(module); - pool.stream() - << inputs - << outputFileTags - << auxiliaryInputs - << excludedAuxiliaryInputs - << inputsFromDependencies - << explicitlyDependsOn - << multiplex - << alwaysRun; - + inputs.store(pool); + outputFileTags.store(pool); + auxiliaryInputs.store(pool); + excludedAuxiliaryInputs.store(pool); + inputsFromDependencies.store(pool); + explicitlyDependsOn.store(pool); + pool.stream() << multiplex << alwaysRun; pool.storeContainer(artifacts); } @@ -504,9 +494,8 @@ FileTags ResolvedProduct::fileTagsForFileName(const QString &fileName) const void ResolvedProduct::load(PersistentPool &pool) { - pool.stream() - >> enabled - >> fileTags; + pool.stream() >> enabled; + fileTags.load(pool); name = pool.idLoadString(); profile = pool.idLoadString(); targetName = pool.idLoadString(); @@ -528,9 +517,8 @@ void ResolvedProduct::load(PersistentPool &pool) void ResolvedProduct::store(PersistentPool &pool) const { - pool.stream() - << enabled - << fileTags; + pool.stream() << enabled; + fileTags.store(pool); pool.storeString(name); pool.storeString(profile); pool.storeString(targetName); @@ -1283,7 +1271,8 @@ bool artifactPropertyListsAreEqual(const QList<ArtifactPropertiesPtr> &l1, void ResolvedScanner::load(PersistentPool &pool) { module = pool.idLoadS<ResolvedModule>(); - pool.stream() >> inputs >> recursive; + inputs.load(pool); + pool.stream() >> recursive; searchPathsScript = pool.idLoadS<ScriptFunction>(); scanScript = pool.idLoadS<ScriptFunction>(); } @@ -1291,7 +1280,8 @@ void ResolvedScanner::load(PersistentPool &pool) void ResolvedScanner::store(PersistentPool &pool) const { pool.store(module); - pool.stream() << inputs << recursive; + inputs.store(pool); + pool.stream() << recursive; pool.store(searchPathsScript); pool.store(scanScript); } diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp index fb4dbf70e..82890b688 100644 --- a/src/lib/corelib/tools/persistence.cpp +++ b/src/lib/corelib/tools/persistence.cpp @@ -50,7 +50,7 @@ namespace qbs { namespace Internal { -static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-91"; +static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-92"; PersistentPool::PersistentPool(Logger &logger) : m_logger(logger) { |