From cc857961747f075d37555dee0ca40ed6da0deb65 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 31 May 2023 09:58:44 +0200 Subject: [PATCH] QVariant: simplify condition guarding customClear() calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Edward Welbourne (cherry picked from commit 3a7ddd7274d93012a57fbe2e47185d921b7a66d1) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qvariant.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 8bfc5334f7d..93ba110552e 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -570,7 +570,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); } @@ -1061,7 +1061,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 = {}; }