diff options
| author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-07-22 18:03:05 +0200 |
|---|---|---|
| committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-07-23 12:08:51 +0200 |
| commit | 5b666c9e530ac977c879ee4ea0d59046440b3bd9 (patch) | |
| tree | a0683fca3b84097aa77057c8421f33bc9ac3bb45 | |
| parent | 5c96e5eda1b94aed18d67ee11b9d05d77bfe9b76 (diff) | |
| download | qbs-5b666c9e530ac977c879ee4ea0d59046440b3bd9.tar.gz | |
introduce FileTags::matches
This is faster and easier to use than the
!FileTags::intersect(...).isEmpty() pattern.
Change-Id: I40e27704704df92544748a5d531be3542f91ce87
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
| -rw-r--r-- | src/lib/buildgraph/rulesapplicator.cpp | 7 | ||||
| -rw-r--r-- | src/lib/language/filetags.cpp | 11 | ||||
| -rw-r--r-- | src/lib/language/filetags.h | 1 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/buildgraph/rulesapplicator.cpp b/src/lib/buildgraph/rulesapplicator.cpp index 388da361a..34fdae728 100644 --- a/src/lib/buildgraph/rulesapplicator.cpp +++ b/src/lib/buildgraph/rulesapplicator.cpp @@ -111,9 +111,7 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts) foreach (Artifact *targetArtifact, dep->buildData->targetArtifacts) artifactsToCheck.unite(targetArtifact->transformer->outputs); foreach (Artifact *artifact, artifactsToCheck) { - FileTags matchingFileTags = artifact->fileTags; - matchingFileTags.intersect(usingsFileTags); - if (!matchingFileTags.isEmpty()) + if (artifact->fileTags.matches(usingsFileTags)) usingArtifacts.insert(artifact); } } @@ -279,8 +277,7 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule for (int i = 0; i < m_product->artifactProperties.count(); ++i) { const ArtifactPropertiesConstPtr &props = m_product->artifactProperties.at(i); - FileTags filter = props->fileTagsFilter(); - if (!filter.intersect(outputArtifact->fileTags).isEmpty()) { + if (outputArtifact->fileTags.matches(props->fileTagsFilter())) { outputArtifact->properties = props->propertyMap(); break; } diff --git a/src/lib/language/filetags.cpp b/src/lib/language/filetags.cpp index c7c12b642..0a7b97ae4 100644 --- a/src/lib/language/filetags.cpp +++ b/src/lib/language/filetags.cpp @@ -54,6 +54,17 @@ FileTags FileTags::fromStringList(const QStringList &strings) return result; } +/*! + * \return \c{true} if this file tags set has file tags in common with \c{other}. + */ +bool FileTags::matches(const FileTags &other) const +{ + for (FileTags::const_iterator it = other.begin(); it != other.end(); ++it) + if (contains(*it)) + return true; + return false; +} + LogWriter operator <<(LogWriter w, const FileTags &tags) { bool firstLoop = true; diff --git a/src/lib/language/filetags.h b/src/lib/language/filetags.h index cebdc84b0..6f269548f 100644 --- a/src/lib/language/filetags.h +++ b/src/lib/language/filetags.h @@ -65,6 +65,7 @@ class FileTags : public QSet<FileTag> public: QStringList toStringList() const; static FileTags fromStringList(const QStringList &strings); + bool matches(const FileTags &other) const; }; LogWriter operator <<(LogWriter w, const FileTags &tags); |
