aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2024-04-20 17:05:19 +0300
committerVladimir Belyavsky <belyavskyv@gmail.com>2024-04-22 08:06:26 +0000
commit6f3ab82691d0f96ea83d2711c284cb4f451cf047 (patch)
tree3f0d16b6d6566b9d4e5b5889625462e1317fbf6d
parentca207f3e63f91426589f7afc775ae3fecc5e49b2 (diff)
QQmlObjectCreator: avoid extra detach on pendingBindings list
Do not detach on pendingBindings list when there is nothing to remove in removePendingBinding() call. Previously it was always detached due to the use of non-const iterators. To avoid this, we can use QList::removeIf() which doesn't detach if there is nothing to remove and also makes the code a bit clearer. Change-Id: Ic2f8c30dcedcac5217e685c0dae55d7fb1615022 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index ef03b1909e..8b1c251e2b 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -165,11 +165,9 @@ public:
void removePendingBinding(QObject *target, int propertyIndex)
{
QList<DeferredQPropertyBinding> &pendingBindings = sharedState.data()->allQPropertyBindings;
- auto it = std::remove_if(pendingBindings.begin(), pendingBindings.end(),
- [&](const DeferredQPropertyBinding &deferred) {
+ pendingBindings.removeIf([&](const DeferredQPropertyBinding &deferred) {
return deferred.properyIndex == propertyIndex && deferred.target == target;
});
- pendingBindings.erase(it, pendingBindings.end());
}
private: