diff options
author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2024-04-20 20:38:14 +0300 |
---|---|---|
committer | Vladimir Belyavsky <belyavskyv@gmail.com> | 2024-04-22 11:06:30 +0300 |
commit | f854150d0a53bf774ef31746ad7875ec3abe4945 (patch) | |
tree | 0a3fca5b45072e4eccc962d97a014a0a3015ba71 | |
parent | 9bf6218b2d752261567fa5ab9ce2e2cb3b0312e7 (diff) |
QQmlComponent: Avoid potential extra QList detach
There might be potential extra QList detach due to the use of non-const
QList iterators in QQmlComponentPrivate::beginCreate(). 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: I87863c1e045926e27deeeece35be9c51de49ab7b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index c6b2434146..c7b9b15bc6 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1049,11 +1049,7 @@ QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData> conte // filter out temporary errors as they do not really affect component's // state (they are not part of the document compilation) - state.errors.erase(std::remove_if(state.errors.begin(), state.errors.end(), - [](const QQmlComponentPrivate::AnnotatedQmlError &e) { - return e.isTransient; - }), - state.errors.end()); + state.errors.removeIf([](const auto &e) { return e.isTransient; }); state.clearRequiredProperties(); if (!q->isReady()) { |