summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-08-09 10:17:11 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-19 13:41:02 (GMT)
commit23717f80cd0f2e6a63aaabc1f62a377d13f76540 (patch)
treed69ec975a618f180ca4b1a279c0b20661be77440 /tools/linguist
parent3f67fd3cbfe6804614dc5be7c64bef2fa8af180a (diff)
downloadQt-23717f80cd0f2e6a63aaabc1f62a377d13f76540.zip
Qt-23717f80cd0f2e6a63aaabc1f62a377d13f76540.tar.gz
Qt-23717f80cd0f2e6a63aaabc1f62a377d13f76540.tar.bz2
execute some loops even in cumulative mode
we execute foreach loops now. this is (mostly) safe nowadays, because a previous change added precautions against exponential value list growth, so it's unlikely that two nested loops would keep the cpu busy for a day as before. we continue to exclude forever loops and loops with excessive integer counts. Task-number: QTBUG-8550 Change-Id: Iaa116086986cc7fd5023834753f791dd205102e5 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> (cherry picked from qttools/dd4d594c787a62fa8aa12695c5d115c71b59bacd)
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/shared/profileevaluator.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp
index 10804c4..a77ff33 100644
--- a/tools/linguist/shared/profileevaluator.cpp
+++ b/tools/linguist/shared/profileevaluator.cpp
@@ -927,13 +927,7 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProBlock(
okey = true, or_op = false; // force next evaluation
break;
case TokForLoop:
- if (m_cumulative) { // This is a no-win situation, so just pretend it's no loop
- skipHashStr(tokPtr);
- uint exprLen = getBlockLen(tokPtr);
- tokPtr += exprLen;
- blockLen = getBlockLen(tokPtr);
- ret = visitProBlock(tokPtr);
- } else if (okey != or_op) {
+ if (m_cumulative || okey != or_op) {
const ProString &variable = getHashStr(tokPtr);
uint exprLen = getBlockLen(tokPtr);
const ushort *exprPtr = tokPtr;
@@ -1063,6 +1057,10 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProLoop(
ProStringList list = valuesDirect(it_list);
if (list.isEmpty()) {
if (it_list == statics.strforever) {
+ if (m_cumulative) {
+ // The termination conditions wouldn't be evaluated, so we must skip it.
+ return ReturnFalse;
+ }
infinite = true;
} else {
const QString &itl = it_list.toQString(m_tmp1);
@@ -1073,6 +1071,11 @@ ProFileEvaluator::Private::VisitReturn ProFileEvaluator::Private::visitProLoop(
if (ok) {
int end = itl.mid(dotdot+2).toInt(&ok);
if (ok) {
+ if (m_cumulative && qAbs(end - start) > 100) {
+ // Such a loop is unlikely to contribute something useful to the
+ // file collection, and may cause considerable delay.
+ return ReturnFalse;
+ }
if (start < end) {
for (int i = start; i <= end; i++)
list << ProString(QString::number(i), NoHash);