From: Kent Hansen Date: Wed, 11 Jul 2012 23:01:17 +0000 (+0200) Subject: statemachine: Move invariant code out of loop body X-Git-Tag: v5.0.0-beta1~831 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b76014b8ef3862b4168148cb20e1108d9c0df5f6;p=profile%2Fivi%2Fqtbase.git statemachine: Move invariant code out of loop body The lca variable doesn't change inside the loop. Comparing our implementation to the algorithm in the SCXML spec reveals that this check should indeed be done outside the loop. Change-Id: I5e9824758fd147766e975d107a73561bd7f5a190 Reviewed-by: Eskil Abrahamsen Blomfeldt --- diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index a83737d..ccc40ac 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -517,12 +517,12 @@ QList QStateMachinePrivate::computeStatesToEnter(const QList lcac = QStatePrivate::get(lca)->childStates(); - foreach (QAbstractState* child,lcac) { - if (!statesToEnter.contains(child)) - addStatesToEnter(child,lca,statesToEnter,statesForDefaultEntry); - } + } + if (isParallel(lca)) { + QList lcac = QStatePrivate::get(lca)->childStates(); + foreach (QAbstractState* child,lcac) { + if (!statesToEnter.contains(child)) + addStatesToEnter(child,lca,statesToEnter,statesForDefaultEntry); } } }