QVariant: simplify condition guarding customClear() calls

Due to short-cut evaluation of the built-in op||, we can do the
following transformation:

    - (X && Y) || !X
    + !X || Y

Change-Id: Ia5ae1dd60bdb663aa4648c09372be1598591110d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 3a7ddd7274d93012a57fbe2e47185d921b7a66d1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-05-31 09:58:44 +02:00 committed by Qt Cherry-pick Bot
parent 9832fb96f6
commit cc85796174

View File

@ -570,7 +570,7 @@ void QVariant::create(QMetaType type, const void *copy)
QVariant::~QVariant() QVariant::~QVariant()
{ {
if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared)) if (!d.is_shared || !d.data.shared->ref.deref())
customClear(&d); customClear(&d);
} }
@ -1061,7 +1061,7 @@ const char *QVariant::typeName() const
*/ */
void QVariant::clear() void QVariant::clear()
{ {
if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared)) if (!d.is_shared || !d.data.shared->ref.deref())
customClear(&d); customClear(&d);
d = {}; d = {};
} }