From 1d3503b8f3b49b0f684e1caa504deb0d05f2c60a Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 1 Feb 2016 11:49:22 +0300 Subject: qmake: use reserve to optimize memory allocation. Change-Id: I6ace338512c24fd9dc11c767a28f0a63454076fa Reviewed-by: Oswald Buddenhagen --- qmake/library/qmakeevaluator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qmake/library/qmakeevaluator.cpp') diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index a772f54a11..d7fe14c02f 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -186,6 +186,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)); } @@ -755,12 +756,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)); -- cgit v1.2.3