summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine/qstate_p.h
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-10-28 14:09:47 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-10-28 14:35:07 (GMT)
commit5d8dcd57cd13fdd9c8643fa3bdda9f197a4351ff (patch)
treefe37e87419eeaf01b0f4a441b3694fac35e15111 /src/corelib/statemachine/qstate_p.h
parent36e362cffe74d8f7fb3eb6b6a67fbab2ebda1a21 (diff)
downloadQt-5d8dcd57cd13fdd9c8643fa3bdda9f197a4351ff.zip
Qt-5d8dcd57cd13fdd9c8643fa3bdda9f197a4351ff.tar.gz
Qt-5d8dcd57cd13fdd9c8643fa3bdda9f197a4351ff.tar.bz2
Greatly improve the performance of obtaining a state's transitions
Transitions are children of their source state. We use QObject::children() and qobject_cast() each child to a QAbstractTransition to see if it is indeed a transition. However, calling qobject_cast() is very expensive. This commit introduces a cached list of transitions. The list is invalidated after a child object has been added or removed. In the typical case we expect the object hierarchy to remain fairly constant once the state machine has been started (states, child states and transitions are usually "static"), in other words the cached list is not likely to be invalidated much. Obtaining a state's transitions needs to be as fast as possible because it's in the critical path of the state machine algorithm. Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src/corelib/statemachine/qstate_p.h')
-rw-r--r--src/corelib/statemachine/qstate_p.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 20cda29..3b5f416 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -99,6 +99,8 @@ public:
QAbstractState *errorState;
QAbstractState *initialState;
QState::ChildMode childMode;
+ mutable bool transitionsListNeedsRefresh;
+ mutable QList<QAbstractTransition*> transitionsList;
QList<QPropertyAssignment> propertyAssignments;
};