summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreevent.h
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-11-11 00:15:25 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-11-12 22:38:29 +0100
commit062ba97f86a7ec07c8f83636857f1fed097acb92 (patch)
tree3271da18740911f204d6aa7d905524cc4ac4b8ea /src/corelib/kernel/qcoreevent.h
parentd5ae51e0f5fb55f0a9f1c57d967bfa1ca67a75e4 (diff)
Drop the d-pointer of QEvent
It's not been used ever since it was added in the Qt 2 days, other than a hack in QGraphicsView that could be solved more elegantly. With this change, QEvent is only 16 bytes large, which is nicely aligned with C++'s default operator new alignment, and we still have plenty of bits (plus an unused bool) left for extensions. Change-Id: If9376d90b92983db7fc12575f3893064a1797adf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcoreevent.h')
-rw-r--r--src/corelib/kernel/qcoreevent.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index cfaa959dec..edd67b79d3 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -320,20 +320,19 @@ protected:
QEvent(Type type, PointerEventTag) : QEvent(type, InputEventTag{}) { m_pointerEvent = true; }
struct SinglePointEventTag { explicit SinglePointEventTag() = default; };
QEvent(Type type, SinglePointEventTag) : QEvent(type, PointerEventTag{}) { m_singlePointEvent = true; }
- QEventPrivate *d = nullptr;
quint16 t;
private:
/*
We can assume that C++ types are 8-byte aligned, and we can't assume that compilers
coalesce data members from subclasses. Use bitfields to fill up to next 8-byte
- aligned size, which is 24 bytes. That way we don't waste memory, and have plenty of room
+ aligned size, which is 16 bytes. That way we don't waste memory, and have plenty of room
for future flags.
Don't use bitfields for the most important flags, as that would generate more code, and
access is always inline. Bytes used are:
- 8 vptr + 8 d-pointer + 2 type + 3 bool flags => 3 bytes left, so 24 bits. However,
- compiler will add padding after the booleans, so add another unused bool, which leaves
- us with 16 bits.
+ 8 vptr + 2 type + 3 bool flags => 3 bytes left, so 24 bits. However, compilers will word-
+ align the quint16s after the bools, so add another unused bool to fill that gap, which
+ leaves us with 16 bits.
*/
bool m_posted = false;
bool m_spont = false;