summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine/qabstractstate.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-10-29 14:28:02 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-10-30 09:12:58 (GMT)
commit83fff2f970b9a7b41861336c7dca0eadbda28099 (patch)
treeacbd743e52fe10c281755fb07e769732ce56f696 /src/corelib/statemachine/qabstractstate.cpp
parentdc4e074324eb91a8a16e14c86ff41b03647b4cfa (diff)
downloadQt-83fff2f970b9a7b41861336c7dca0eadbda28099.zip
Qt-83fff2f970b9a7b41861336c7dca0eadbda28099.tar.gz
Qt-83fff2f970b9a7b41861336c7dca0eadbda28099.tar.bz2
Introduce internal StateType to avoid excessive qobject_casts
The state machine algorithm frequently needs to know what type a state is, e.g. if it is atomic, final or a history state. We were using qobject_cast() to determine this, but that function is expensive. This commit introduces an internal StateType to be able to differentiate between the different types of state. This vastly improves performance. Reviewed-by: Eskil Abrahamsen Blomfeldt
Diffstat (limited to 'src/corelib/statemachine/qabstractstate.cpp')
-rw-r--r--src/corelib/statemachine/qabstractstate.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp
index cf67cdd..ec5332f 100644
--- a/src/corelib/statemachine/qabstractstate.cpp
+++ b/src/corelib/statemachine/qabstractstate.cpp
@@ -78,8 +78,8 @@ QT_BEGIN_NAMESPACE
function to perform custom processing when the state is exited.
*/
-QAbstractStatePrivate::QAbstractStatePrivate()
- : parentState(0)
+QAbstractStatePrivate::QAbstractStatePrivate(StateType type)
+ : stateType(type), isMachine(false), parentState(0)
{
}
@@ -88,6 +88,11 @@ QAbstractStatePrivate *QAbstractStatePrivate::get(QAbstractState *q)
return q->d_func();
}
+const QAbstractStatePrivate *QAbstractStatePrivate::get(const QAbstractState *q)
+{
+ return q->d_func();
+}
+
QStateMachine *QAbstractStatePrivate::machine() const
{
QObject *par = parent;
@@ -127,7 +132,7 @@ void QAbstractStatePrivate::emitExited()
Constructs a new state with the given \a parent state.
*/
QAbstractState::QAbstractState(QState *parent)
- : QObject(*new QAbstractStatePrivate, parent)
+ : QObject(*new QAbstractStatePrivate(QAbstractStatePrivate::AbstractState), parent)
{
}