summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-02-23 12:59:21 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-27 12:57:30 +0100
commit184c9e346e298bbda2cc8f30e2f318c1c11e4b13 (patch)
tree58f4a168591cb0a98175fee45e59520bd9e7bbd6
parentbeab403d9fcf1fb41f3c133fc6d58e1e864a8d56 (diff)
Optimize space for the QEventLoopQuitLocker.
Use a union and a type enum instead of three pointers. Change-Id: I02b11733a4f2e95099064fa9325497d4e04ac615 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
-rw-r--r--src/corelib/kernel/qeventloop.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index 2fb351797c..dfdd178c35 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -322,37 +322,51 @@ class QEventLoopLockerPrivate
{
public:
explicit QEventLoopLockerPrivate(QEventLoopPrivate *loop)
- : loop(loop), thread(0), app(0)
+ : loop(loop), type(EventLoop)
{
loop->ref();
}
explicit QEventLoopLockerPrivate(QThreadPrivate *thread)
- : loop(0), thread(thread), app(0)
+ : thread(thread), type(Thread)
{
thread->ref();
}
explicit QEventLoopLockerPrivate(QCoreApplicationPrivate *app)
- : loop(0), thread(0), app(app)
+ : app(app), type(Application)
{
app->ref();
}
~QEventLoopLockerPrivate()
{
- if (loop)
+ switch (type)
+ {
+ case EventLoop:
loop->deref();
- else if (thread)
+ break;
+ case Thread:
thread->deref();
- else
+ break;
+ default:
app->deref();
+ break;
+ }
}
private:
- QEventLoopPrivate *loop;
- QThreadPrivate *thread;
- QCoreApplicationPrivate *app;
+ union {
+ QEventLoopPrivate * loop;
+ QThreadPrivate * thread;
+ QCoreApplicationPrivate * app;
+ };
+ enum Type {
+ EventLoop,
+ Thread,
+ Application
+ };
+ const Type type;
};
/*!