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

Pick-to: 6.5
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>
bb10
Marc Mutz 2023-05-31 09:58:44 +02:00
parent 496bd9e975
commit 3a7ddd7274
1 changed files with 2 additions and 2 deletions

View File

@ -502,7 +502,7 @@ void QVariant::create(QMetaType type, const void *copy)
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);
}
@ -1030,7 +1030,7 @@ const char *QVariant::typeName() const
*/
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);
d = {};
}