diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-07-07 15:44:13 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-07 21:20:04 +0200 |
commit | 652459afde5d1ed350f198f212d19b067ce5c1a3 (patch) | |
tree | 0d4b93a884f8e4201c7c0d2f89cb1baee91db8aa | |
parent | 086ca457b524d826af5fc5e184bd8f649c431c21 (diff) |
Improve performance of property binding evaluation
Improves performance of binding evaluation by ~20% for
simple C++ bindings by simplifying and inlining the code
that clears the array of property observers.
Change-Id: I829ac1895f1673367d737944d950360015a5b435
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qproperty.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qpropertybinding_p.h | 6 |
3 files changed, 4 insertions, 6 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index b362319f22..f62810518b 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -279,8 +279,6 @@ QPropertyObserver::~QPropertyObserver() d.unlink(); } -QPropertyObserver::QPropertyObserver() = default; - QPropertyObserver::QPropertyObserver(QPropertyObserver &&other) { std::swap(bindingToMarkDirty, other.bindingToMarkDirty); diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 4a323fe8fe..994eb24cea 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -607,7 +607,7 @@ public: ObserverNotifiesAlias, }; - QPropertyObserver(); + QPropertyObserver() = default; QPropertyObserver(QPropertyObserver &&other); QPropertyObserver &operator=(QPropertyObserver &&other); ~QPropertyObserver(); diff --git a/src/corelib/kernel/qpropertybinding_p.h b/src/corelib/kernel/qpropertybinding_p.h index 151f5543d5..6257e4506e 100644 --- a/src/corelib/kernel/qpropertybinding_p.h +++ b/src/corelib/kernel/qpropertybinding_p.h @@ -148,9 +148,9 @@ public: void clearDependencyObservers() { if (!hasStaticObserver) { - for (size_t i = 0; i < inlineDependencyObservers.size(); ++i) { - QPropertyObserver empty; - qSwap(inlineDependencyObservers[i], empty); + for (size_t i = 0; i < qMin(dependencyObserverCount, inlineDependencyObservers.size()); ++i) { + QPropertyObserverPointer p{&inlineDependencyObservers[i]}; + p.unlink(); } } if (heapObservers) |