diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-01-13 10:11:46 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-01-26 17:44:19 +0100 |
commit | cde904b38ab6ef1ddcc9a0cbcae766cf42d58d81 (patch) | |
tree | dc365ecc97262192317a5935448640ee2d227c43 /mkspecs | |
parent | ce9d708d514011db1ab45630c95222d2a30c7550 (diff) |
Q<Typed>Permission: don't use external state
There's no point in using the full implicit sharing machinery when the
type's state consists of two enums, a bool or, indeed, if the type has
no state at all. QRect has more state and isn't implicitly shared.
To remain extensible in the future, all that is required is that the
type contains space for an eventual d-pointer and that all access to
members (except swapping, and, as a consequence, the move SFMs, but
including the copy SMFs, ctors and dtor) is confined to out-of-line
functions.
So define a ShortData (name stolen from QDateTime) nested struct in
each of the stateful Q<Typed>Permission classes, of the same size as a
pointer, holding the trivially-relocatable fields we currently have.
If, in the future, fields are added such that the reserved[] space in
any given class' ShortData no longer suffices to hold them, or said
fields are not of Q_RELOCATABLE_TYPE, then the full d-pointer pattern
(with an actually defined Private, and detach()ing) can be implemented
_for that one class_.
The new-style classes are externally indistinguishable from the
implicitly-shared old-style ones, just a lot more efficient.
Inline the move-ctor, now that we can. This doesn't break
encapsulation, even when we eventually activate the d-pointer.
As a drive-by, drop the noexcept on the dtors - dtors are implicitly
noexcept, anyway.
Pick-to: 6.5
Change-Id: Id90a39227277c6554ddd5895e8205485da1e39ca
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'mkspecs')
0 files changed, 0 insertions, 0 deletions