forked from qt-creator/qt-creator
avoid indexed access to elements of the value map stack
this makes us independent from the random access performance of the underlying container. Change-Id: I0e655320ad607ac43ef6797e52e6179570c155f4 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
@@ -82,7 +82,7 @@ QStringList ProFileEvaluator::values(const QString &variableName) const
|
|||||||
QStringList ProFileEvaluator::values(const QString &variableName, const ProFile *pro) const
|
QStringList ProFileEvaluator::values(const QString &variableName, const ProFile *pro) const
|
||||||
{
|
{
|
||||||
// It makes no sense to put any kind of magic into expanding these
|
// It makes no sense to put any kind of magic into expanding these
|
||||||
const ProStringList &values = d->m_valuemapStack.at(0).value(ProKey(variableName));
|
const ProStringList &values = d->m_valuemapStack.first().value(ProKey(variableName));
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
ret.reserve(values.size());
|
ret.reserve(values.size());
|
||||||
foreach (const ProString &str, values)
|
foreach (const ProString &str, values)
|
||||||
|
@@ -1089,18 +1089,19 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
|||||||
return ReturnFalse;
|
return ReturnFalse;
|
||||||
}
|
}
|
||||||
const ProKey &var = map(args.at(0));
|
const ProKey &var = map(args.at(0));
|
||||||
for (int i = m_valuemapStack.size(); --i > 0; ) {
|
for (ProValueMapStack::Iterator vmi = m_valuemapStack.end();
|
||||||
ProValueMap::Iterator it = m_valuemapStack[i].find(var);
|
--vmi != m_valuemapStack.begin(); ) {
|
||||||
if (it != m_valuemapStack.at(i).end()) {
|
ProValueMap::Iterator it = (*vmi).find(var);
|
||||||
|
if (it != (*vmi).end()) {
|
||||||
if (it->constBegin() == statics.fakeValue.constBegin()) {
|
if (it->constBegin() == statics.fakeValue.constBegin()) {
|
||||||
// This is stupid, but qmake doesn't propagate deletions
|
// This is stupid, but qmake doesn't propagate deletions
|
||||||
m_valuemapStack[0][var] = ProStringList();
|
m_valuemapStack.first()[var] = ProStringList();
|
||||||
} else {
|
} else {
|
||||||
m_valuemapStack[0][var] = *it;
|
m_valuemapStack.first()[var] = *it;
|
||||||
}
|
}
|
||||||
m_valuemapStack[i].erase(it);
|
(*vmi).erase(it);
|
||||||
while (--i)
|
while (--vmi != m_valuemapStack.begin())
|
||||||
m_valuemapStack[i].remove(var);
|
(*vmi).remove(var);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1304,7 +1304,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile(
|
|||||||
#ifdef QT_BUILD_QMAKE
|
#ifdef QT_BUILD_QMAKE
|
||||||
for (ProValueMap::ConstIterator it = m_extraVars.constBegin();
|
for (ProValueMap::ConstIterator it = m_extraVars.constBegin();
|
||||||
it != m_extraVars.constEnd(); ++it)
|
it != m_extraVars.constEnd(); ++it)
|
||||||
m_valuemapStack[0].insert(it.key(), it.value());
|
m_valuemapStack.first().insert(it.key(), it.value());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_handler->aboutToEval(currentProFile(), pro, type);
|
m_handler->aboutToEval(currentProFile(), pro, type);
|
||||||
@@ -1673,15 +1673,17 @@ void QMakeEvaluator::checkRequirements(const ProStringList &deps)
|
|||||||
|
|
||||||
ProValueMap *QMakeEvaluator::findValues(const ProKey &variableName, ProValueMap::Iterator *rit)
|
ProValueMap *QMakeEvaluator::findValues(const ProKey &variableName, ProValueMap::Iterator *rit)
|
||||||
{
|
{
|
||||||
for (int i = m_valuemapStack.size(); --i >= 0; ) {
|
ProValueMapStack::Iterator vmi = m_valuemapStack.end();
|
||||||
ProValueMap::Iterator it = m_valuemapStack[i].find(variableName);
|
do {
|
||||||
if (it != m_valuemapStack[i].end()) {
|
--vmi;
|
||||||
|
ProValueMap::Iterator it = (*vmi).find(variableName);
|
||||||
|
if (it != (*vmi).end()) {
|
||||||
if (it->constBegin() == statics.fakeValue.constBegin())
|
if (it->constBegin() == statics.fakeValue.constBegin())
|
||||||
return 0;
|
return 0;
|
||||||
*rit = it;
|
*rit = it;
|
||||||
return &m_valuemapStack[i];
|
return &(*vmi);
|
||||||
}
|
}
|
||||||
}
|
} while (vmi != m_valuemapStack.begin());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1693,28 +1695,34 @@ ProStringList &QMakeEvaluator::valuesRef(const ProKey &variableName)
|
|||||||
it->clear();
|
it->clear();
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
for (int i = m_valuemapStack.size() - 1; --i >= 0; ) {
|
ProValueMapStack::Iterator vmi = m_valuemapStack.end();
|
||||||
ProValueMap::ConstIterator it = m_valuemapStack.at(i).constFind(variableName);
|
if (--vmi != m_valuemapStack.begin()) {
|
||||||
if (it != m_valuemapStack.at(i).constEnd()) {
|
do {
|
||||||
ProStringList &ret = m_valuemapStack.top()[variableName];
|
--vmi;
|
||||||
if (it->constBegin() != statics.fakeValue.constBegin())
|
ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
|
||||||
ret = *it;
|
if (it != (*vmi).constEnd()) {
|
||||||
return ret;
|
ProStringList &ret = m_valuemapStack.top()[variableName];
|
||||||
}
|
if (it->constBegin() != statics.fakeValue.constBegin())
|
||||||
|
ret = *it;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
} while (vmi != m_valuemapStack.begin());
|
||||||
}
|
}
|
||||||
return m_valuemapStack.top()[variableName];
|
return m_valuemapStack.top()[variableName];
|
||||||
}
|
}
|
||||||
|
|
||||||
ProStringList QMakeEvaluator::values(const ProKey &variableName) const
|
ProStringList QMakeEvaluator::values(const ProKey &variableName) const
|
||||||
{
|
{
|
||||||
for (int i = m_valuemapStack.size(); --i >= 0; ) {
|
ProValueMapStack::ConstIterator vmi = m_valuemapStack.constEnd();
|
||||||
ProValueMap::ConstIterator it = m_valuemapStack.at(i).constFind(variableName);
|
do {
|
||||||
if (it != m_valuemapStack.at(i).constEnd()) {
|
--vmi;
|
||||||
|
ProValueMap::ConstIterator it = (*vmi).constFind(variableName);
|
||||||
|
if (it != (*vmi).constEnd()) {
|
||||||
if (it->constBegin() == statics.fakeValue.constBegin())
|
if (it->constBegin() == statics.fakeValue.constBegin())
|
||||||
break;
|
break;
|
||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
}
|
} while (vmi != m_valuemapStack.constBegin());
|
||||||
return ProStringList();
|
return ProStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,6 +71,8 @@ public:
|
|||||||
virtual void doneWithEval(ProFile *parent) = 0;
|
virtual void doneWithEval(ProFile *parent) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef QStack<ProValueMap> ProValueMapStack;
|
||||||
|
|
||||||
class QMAKE_EXPORT QMakeEvaluator
|
class QMAKE_EXPORT QMakeEvaluator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -265,7 +267,7 @@ public:
|
|||||||
ProString m_dirSep;
|
ProString m_dirSep;
|
||||||
ProFunctionDefs m_functionDefs;
|
ProFunctionDefs m_functionDefs;
|
||||||
ProStringList m_returnValue;
|
ProStringList m_returnValue;
|
||||||
QStack<ProValueMap> m_valuemapStack; // VariableName must be us-ascii, the content however can be non-us-ascii.
|
ProValueMapStack m_valuemapStack; // VariableName must be us-ascii, the content however can be non-us-ascii.
|
||||||
QString m_tmp1, m_tmp2, m_tmp3, m_tmp[2]; // Temporaries for efficient toQString
|
QString m_tmp1, m_tmp2, m_tmp3, m_tmp[2]; // Temporaries for efficient toQString
|
||||||
mutable QString m_mtmp;
|
mutable QString m_mtmp;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user