Commit 3f4e40e3 authored by Anton Kudryavtsev's avatar Anton Kudryavtsev Committed by Oswald Buddenhagen

qmake: use reserve to optimize memory allocation

Change-Id: I6ace338512c24fd9dc11c767a28f0a63454076fa
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
(cherry picked from qtbase/1d3503b8f3b49b0f684e1caa504deb0d05f2c60a)
Reviewed-by: Jake Petroules's avatarJake Petroules <jake.petroules@qt.io>
Reviewed-by: default avatarAnton Kudryavtsev <a.kudryavtsev@netris.ru>
parent d882ae9c
......@@ -146,6 +146,7 @@ void QMakeEvaluator::initFunctionStatics()
{ "shell_quote", E_SHELL_QUOTE },
{ "getenv", E_GETENV },
};
statics.expands.reserve((int)(sizeof(expandInits)/sizeof(expandInits[0])));
for (unsigned i = 0; i < sizeof(expandInits)/sizeof(expandInits[0]); ++i)
statics.expands.insert(ProKey(expandInits[i].name), expandInits[i].func);
......@@ -187,6 +188,7 @@ void QMakeEvaluator::initFunctionStatics()
{ "touch", T_TOUCH },
{ "cache", T_CACHE },
};
statics.functions.reserve((int)(sizeof(testInits)/sizeof(testInits[0])));
for (unsigned i = 0; i < sizeof(testInits)/sizeof(testInits[0]); ++i)
statics.functions.insert(ProKey(testInits[i].name), testInits[i].func);
}
......
......@@ -183,6 +183,7 @@ void QMakeEvaluator::initStatics()
{ "IN_PWD", "PWD" },
{ "DEPLOYMENT", "INSTALLS" }
};
statics.varMap.reserve((int)(sizeof(mapInits)/sizeof(mapInits[0])));
for (unsigned i = 0; i < sizeof(mapInits)/sizeof(mapInits[0]); ++i)
statics.varMap.insert(ProKey(mapInits[i].oldname), ProKey(mapInits[i].newname));
}
......@@ -760,12 +761,14 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
if (ok) {
int end = itl.mid(dotdot+2).toInt(&ok);
if (ok) {
if (m_cumulative && qAbs(end - start) > 100) {
const int absDiff = qAbs(end - start);
if (m_cumulative && absDiff > 100) {
// Such a loop is unlikely to contribute something useful to the
// file collection, and may cause considerable delay.
traceMsg("skipping excessive loop in cumulative mode");
return ReturnFalse;
}
list.reserve(absDiff + 1);
if (start < end) {
for (int i = start; i <= end; i++)
list << ProString(QString::number(i));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment