From b01f08033be1f83294e4ac9e49e17598e509a6f0 Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Fri, 29 Oct 2021 16:20:28 +0200 Subject: [PATCH] Inline QPropertyBindingDataPointer The only non-inline function of that class was observerCount() which would use two of the inline functions defined in the header file, so we can safely inline observerCount() and make the whole class contain only inline methods Consequently, inline class doesn't have to be exported in Windows Change-Id: I41d144d9a50420bbc0091992b36cc36ac2567704 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qproperty.cpp | 7 ------- src/corelib/kernel/qproperty_p.h | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index f8299b5d29b..b57ba7851af 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -608,13 +608,6 @@ QPropertyBindingData::NotificationResult QPropertyBindingData::notifyObserver_he return Evaluated; } -int QPropertyBindingDataPointer::observerCount() const -{ - int count = 0; - for (auto observer = firstObserver(); observer; observer = observer.nextObserver()) - ++count; - return count; -} QPropertyObserver::QPropertyObserver(ChangeHandler changeHandler) { diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index cafe211e711..5105fd63437 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -68,7 +68,7 @@ namespace QtPrivate { // we need to allow the compiler to inline where it makes sense. // This is a helper "namespace" -struct Q_AUTOTEST_EXPORT QPropertyBindingDataPointer +struct QPropertyBindingDataPointer { const QtPrivate::QPropertyBindingData *ptr = nullptr; @@ -85,10 +85,10 @@ struct Q_AUTOTEST_EXPORT QPropertyBindingDataPointer } static void fixupAfterMove(QtPrivate::QPropertyBindingData *ptr); void Q_ALWAYS_INLINE addObserver(QPropertyObserver *observer); - void setFirstObserver(QPropertyObserver *observer); - QPropertyObserverPointer firstObserver() const; + inline void setFirstObserver(QPropertyObserver *observer); + inline QPropertyObserverPointer firstObserver() const; - int observerCount() const; + inline int observerCount() const; template static QPropertyBindingDataPointer get(QProperty &property) @@ -442,6 +442,14 @@ inline QPropertyObserverPointer QPropertyBindingDataPointer::firstObserver() con return { reinterpret_cast(ptr->d()) }; } +inline int QPropertyBindingDataPointer::observerCount() const +{ + int count = 0; + for (auto observer = firstObserver(); observer; observer = observer.nextObserver()) + ++count; + return count; +} + namespace QtPrivate { Q_CORE_EXPORT bool isPropertyInBindingWrapper(const QUntypedPropertyData *property); void Q_CORE_EXPORT initBindingStatusThreadId();