diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-07-16 15:56:26 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-07-17 09:56:01 +0200 |
commit | 1c982622acd9e38096dd9feabe8e5a4c129df31c (patch) | |
tree | 0770391f480ffb0425258071cef73a604078e8f0 | |
parent | 4d0a76fafebf11af4ab948e60f9f8eae7097fca8 (diff) |
speed up ResolvedProduct::lookupArtifactsByFileTag
Change-Id: Id2f55d64dcbaf6c1b80009a13d48ed823ee213cd
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
-rw-r--r-- | src/lib/corelib/buildgraph/buildgraph.cpp | 1 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/productbuilddata.cpp | 12 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/productbuilddata.h | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/projectbuilddata.cpp | 1 | ||||
-rw-r--r-- | src/lib/corelib/language/language.cpp | 8 | ||||
-rw-r--r-- | src/lib/corelib/tools/persistence.cpp | 2 |
6 files changed, 18 insertions, 8 deletions
diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp index 0a231a67a..39fdc2851 100644 --- a/src/lib/corelib/buildgraph/buildgraph.cpp +++ b/src/lib/corelib/buildgraph/buildgraph.cpp @@ -437,6 +437,7 @@ void insertArtifact(const ResolvedProductPtr &product, Artifact *artifact, const } #endif product->buildData->nodes.insert(artifact); + addArtifactToSet(artifact, product->buildData->artifactsByFileTag); artifact->product = product; product->topLevelProject()->buildData->insertIntoLookupTable(artifact); product->topLevelProject()->buildData->isDirty = true; diff --git a/src/lib/corelib/buildgraph/productbuilddata.cpp b/src/lib/corelib/buildgraph/productbuilddata.cpp index c0e23b2db..5cdf69923 100644 --- a/src/lib/corelib/buildgraph/productbuilddata.cpp +++ b/src/lib/corelib/buildgraph/productbuilddata.cpp @@ -77,6 +77,7 @@ void ProductBuildData::load(PersistentPool &pool) elem.load(pool); rescuableArtifactData.insert(filePath, elem); } + loadArtifactSetByFileTag(pool, artifactsByFileTag); loadArtifactSetByFileTag(pool, addedArtifactsByFileTag); loadArtifactSetByFileTag(pool, removedArtifactsByFileTag); @@ -110,6 +111,7 @@ void ProductBuildData::store(PersistentPool &pool) const pool.storeString(it.key()); it.value().store(pool); } + storeArtifactSetByFileTag(pool, artifactsByFileTag); storeArtifactSetByFileTag(pool, addedArtifactsByFileTag); storeArtifactSetByFileTag(pool, removedArtifactsByFileTag); @@ -127,5 +129,15 @@ void addArtifactToSet(Artifact *artifact, ProductBuildData::ArtifactSetByFileTag container[tag] += artifact; } +void removeArtifactFromSet(Artifact *artifact, ProductBuildData::ArtifactSetByFileTag &container) +{ + foreach (const FileTag &t, artifact->fileTags) { + ArtifactSet &s = container[t]; + s.remove(artifact); + if (s.isEmpty()) + container.remove(t); + } +} + } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/buildgraph/productbuilddata.h b/src/lib/corelib/buildgraph/productbuilddata.h index 61b072c2d..07193ea9a 100644 --- a/src/lib/corelib/buildgraph/productbuilddata.h +++ b/src/lib/corelib/buildgraph/productbuilddata.h @@ -63,6 +63,7 @@ public: unsigned int buildPriority; typedef QHash<FileTag, ArtifactSet> ArtifactSetByFileTag; + ArtifactSetByFileTag artifactsByFileTag; ArtifactSetByFileTag addedArtifactsByFileTag; ArtifactSetByFileTag removedArtifactsByFileTag; @@ -75,6 +76,7 @@ private: }; void addArtifactToSet(Artifact *artifact, ProductBuildData::ArtifactSetByFileTag &container); +void removeArtifactFromSet(Artifact *artifact, ProductBuildData::ArtifactSetByFileTag &container); } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/buildgraph/projectbuilddata.cpp b/src/lib/corelib/buildgraph/projectbuilddata.cpp index 327154e8e..978acecad 100644 --- a/src/lib/corelib/buildgraph/projectbuilddata.cpp +++ b/src/lib/corelib/buildgraph/projectbuilddata.cpp @@ -273,6 +273,7 @@ void ProjectBuildData::removeArtifact(Artifact *artifact, if (removeFromProduct) { artifact->product->buildData->nodes.remove(artifact); artifact->product->buildData->roots.remove(artifact); + removeArtifactFromSet(artifact, artifact->product->buildData->artifactsByFileTag); } // If removal is requested and the executor has not run since the time the artifact was last diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index 6b90011d3..f13a6fb82 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -773,13 +773,7 @@ bool ResolvedProduct::isMarkedForReapplication(const RuleConstPtr &rule) const ArtifactSet ResolvedProduct::lookupArtifactsByFileTag(const FileTag &tag) const { QBS_CHECK(buildData); - // ### slow. improve. - ArtifactSet result; - foreach (Artifact * const a, ArtifactSet::fromNodeSet(buildData->nodes)) { - if (a->fileTags.contains(tag)) - result += a; - } - return result; + return buildData->artifactsByFileTag.value(tag); } ArtifactSet ResolvedProduct::targetArtifacts() const diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp index 5418148b7..d1efac007 100644 --- a/src/lib/corelib/tools/persistence.cpp +++ b/src/lib/corelib/tools/persistence.cpp @@ -40,7 +40,7 @@ namespace qbs { namespace Internal { -static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-71"; +static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-72"; PersistentPool::PersistentPool(const Logger &logger) : m_logger(logger) { |