aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/buildgraph/rulegraph.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-01-31 10:18:24 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-02-21 17:25:16 +0000
commitb1b58a735a8d6f8f9fb586a877c145326f4b1628 (patch)
treec4b4c37e3469df8a355d82bf1b1c882d569a5c2a /src/lib/corelib/buildgraph/rulegraph.cpp
parent1c65b79eb3da939de372b10b603729c4621caba8 (diff)
Remove all usages of Q_FOREACH from the library
This will make it easier to experiment with exchanging Qt containers for STL ones, for instance. Change-Id: Ie591fa54b5241ad4841b1ebcfb78b72932cd2b38 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib/buildgraph/rulegraph.cpp')
-rw-r--r--src/lib/corelib/buildgraph/rulegraph.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/corelib/buildgraph/rulegraph.cpp b/src/lib/corelib/buildgraph/rulegraph.cpp
index 5d206876f..b3eeb8971 100644
--- a/src/lib/corelib/buildgraph/rulegraph.cpp
+++ b/src/lib/corelib/buildgraph/rulegraph.cpp
@@ -41,6 +41,7 @@
#include <language/language.h>
#include <logging/translator.h>
#include <tools/error.h>
+#include <tools/qttools.h>
namespace qbs {
namespace Internal {
@@ -53,8 +54,8 @@ void RuleGraph::build(const Set<RulePtr> &rules, const FileTags &productFileTags
{
QMap<FileTag, QList<const Rule *> > inputFileTagToRule;
m_rules.reserve(rules.count());
- foreach (const RulePtr &rule, rules) {
- foreach (const FileTag &fileTag, rule->collectedOutputFileTags())
+ for (const RulePtr &rule : rules) {
+ for (const FileTag &fileTag : rule->collectedOutputFileTags())
m_outputFileTagToRule[fileTag].append(rule.data());
insert(rule);
}
@@ -62,13 +63,13 @@ void RuleGraph::build(const Set<RulePtr> &rules, const FileTags &productFileTags
m_parents.resize(rules.count());
m_children.resize(rules.count());
- foreach (const RuleConstPtr &rule, m_rules) {
+ for (const RuleConstPtr &rule : qAsConst(m_rules)) {
FileTags inFileTags = rule->inputs;
inFileTags += rule->auxiliaryInputs;
inFileTags += rule->explicitlyDependsOn;
- foreach (const FileTag &fileTag, inFileTags) {
+ for (const FileTag &fileTag : qAsConst(inFileTags)) {
inputFileTagToRule[fileTag].append(rule.data());
- foreach (const Rule * const producingRule, m_outputFileTagToRule.value(fileTag)) {
+ for (const Rule * const producingRule : m_outputFileTagToRule.value(fileTag)) {
if (!producingRule->collectedOutputFileTags().intersects(
rule->excludedAuxiliaryInputs)) {
connect(rule.data(), producingRule);
@@ -78,19 +79,19 @@ void RuleGraph::build(const Set<RulePtr> &rules, const FileTags &productFileTags
}
QList<const Rule *> productRules;
- foreach (const FileTag &productFileTag, productFileTags) {
+ for (const FileTag &productFileTag : productFileTags) {
QList<const Rule *> rules = m_outputFileTagToRule.value(productFileTag);
productRules += rules;
//### check: the rule graph must be a in valid shape!
}
- foreach (const Rule *r, productRules)
+ for (const Rule *r : qAsConst(productRules))
m_rootRules += r->ruleGraphId;
}
void RuleGraph::accept(RuleGraphVisitor *visitor) const
{
const RuleConstPtr nullParent;
- foreach (int rootIndex, m_rootRules)
+ for (int rootIndex : qAsConst(m_rootRules))
traverse(visitor, nullParent, m_rules.at(rootIndex));
}
@@ -99,12 +100,11 @@ void RuleGraph::dump() const
QByteArray indent;
printf("---rule graph dump:\n");
Set<int> rootRules;
- foreach (const RuleConstPtr &rule, m_rules)
+ for (const RuleConstPtr &rule : qAsConst(m_rules))
if (m_parents[rule->ruleGraphId].isEmpty())
rootRules += rule->ruleGraphId;
- foreach (int idx, rootRules) {
+ for (int idx : qAsConst(rootRules))
dump_impl(indent, idx);
- }
}
void RuleGraph::dump_impl(QByteArray &indent, int rootIndex) const
@@ -115,7 +115,7 @@ void RuleGraph::dump_impl(QByteArray &indent, int rootIndex) const
printf("\n");
indent.append(" ");
- foreach (int childIndex, m_children[rootIndex])
+ for (int childIndex : qAsConst(m_children[rootIndex]))
dump_impl(indent, childIndex);
indent.chop(2);
}
@@ -143,7 +143,7 @@ void RuleGraph::traverse(RuleGraphVisitor *visitor, const RuleConstPtr &parentRu
const RuleConstPtr &rule) const
{
visitor->visit(parentRule, rule);
- foreach (int childIndex, m_children.at(rule->ruleGraphId))
+ for (int childIndex : m_children.at(rule->ruleGraphId))
traverse(visitor, rule, m_rules.at(childIndex));
visitor->endVisit(rule);
}