forked from qt-creator/qt-creator
avoid exponential resource consumption
the cumulative mode tries hard to never lose already assigned variable values. the naive implementation turned assignments into additions, which made the trivial construct "FOO = $$FOO" double the size of the array each time it would be executed. so instead let the assignments be assignments, and then re-add the values that would be dropped. Reviewed-by: dt Task-number: QTCREATORBUG-1595
This commit is contained in:
@@ -1211,9 +1211,22 @@ void ProFileEvaluator::Private::visitProVariable(ProVariable *var)
|
|||||||
m_valuemapStack.top()[varName] = varVal;
|
m_valuemapStack.top()[varName] = varVal;
|
||||||
m_filevaluemap[currentProFile()][varName] = varVal;
|
m_filevaluemap[currentProFile()][varName] = varVal;
|
||||||
}
|
}
|
||||||
|
} else if (!varVal.isEmpty()) {
|
||||||
|
// We are greedy for values. But avoid exponential growth.
|
||||||
|
QStringList &v = valuesRef(varName);
|
||||||
|
if (v.isEmpty()) {
|
||||||
|
v = varVal;
|
||||||
} else {
|
} else {
|
||||||
// We are greedy for values.
|
QStringList old = v;
|
||||||
valuesRef(varName) += varVal;
|
v = varVal;
|
||||||
|
QSet<QString> has = v.toSet();
|
||||||
|
v.reserve(v.size() + old.size());
|
||||||
|
foreach (const QString &s, old)
|
||||||
|
if (!has.contains(s))
|
||||||
|
v << s;
|
||||||
|
}
|
||||||
|
// These values will not be used for further processing inside
|
||||||
|
// the evaluator. Duplicate elimination happens later.
|
||||||
m_filevaluemap[currentProFile()][varName] += varVal;
|
m_filevaluemap[currentProFile()][varName] += varVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3346,7 +3359,7 @@ ProFileEvaluator::TemplateType ProFileEvaluator::templateType()
|
|||||||
{
|
{
|
||||||
QStringList templ = values(statics.strTEMPLATE);
|
QStringList templ = values(statics.strTEMPLATE);
|
||||||
if (templ.count() >= 1) {
|
if (templ.count() >= 1) {
|
||||||
const QString &t = templ.last();
|
const QString &t = templ.at(0);
|
||||||
if (!t.compare(QLatin1String("app"), Qt::CaseInsensitive))
|
if (!t.compare(QLatin1String("app"), Qt::CaseInsensitive))
|
||||||
return TT_Application;
|
return TT_Application;
|
||||||
if (!t.compare(QLatin1String("lib"), Qt::CaseInsensitive))
|
if (!t.compare(QLatin1String("lib"), Qt::CaseInsensitive))
|
||||||
|
|||||||
Reference in New Issue
Block a user