From 5cd9d88c2683c5d226ab1dc0384868408c036fe9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 Apr 2018 12:05:21 +0200 Subject: Avoid excessive creation of contexts Variables do not escape if they are being used from an inner block in the same function. Change-Id: I494861edf9d8a492930797928a3137362082d084 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4compilerscanfunctions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index f5bfd14c93..40459b3b28 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -523,6 +523,12 @@ void ScanFunctions::calcEscapingVariables() for (Context *inner : qAsConst(m->contextMap)) { for (const QString &var : qAsConst(inner->usedVariables)) { Context *c = inner; + while (c) { + Context *current = c; + c = c->parent; + if (current->isWithBlock || current->contextType != ContextType::Block) + break; + } while (c) { Context::MemberMap::const_iterator it = c->members.find(var); if (it != c->members.end()) { -- cgit v1.2.3