aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2024-04-22 18:16:24 +0300
committerVladimir Belyavsky <belyavskyv@gmail.com>2024-04-22 20:26:47 +0000
commit19b09affee8698f80d386e3b286753974f6bf10a (patch)
tree9e4d147a36ba22308ad397b455f29478edbe032e /src/qmlworkerscript
parent7b463868de47c5f08f086e9508cb4b41a310f268 (diff)
QtQml: Use QHash/QMap's constFind() to avoid unnecessary detaches
Use QHash/QMap's constFind() instead of non-const find() where applicable to avoid unnecessary detaches. Change-Id: I6b31af1d163d11deb229681ff7e2f6c9f8335d8c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlworkerscript')
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index b4fd21fe7e..f892343b85 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -180,8 +180,8 @@ bool QQuickWorkerScriptEnginePrivate::event(QEvent *event)
} else if (event->type() == (QEvent::Type)WorkerRemoveEvent::WorkerRemove) {
QMutexLocker locker(&m_lock);
WorkerRemoveEvent *workerEvent = static_cast<WorkerRemoveEvent *>(event);
- auto itr = workers.find(workerEvent->workerId());
- if (itr != workers.end()) {
+ auto itr = workers.constFind(workerEvent->workerId());
+ if (itr != workers.cend()) {
if (itr->isT1())
delete itr->asT1();
workers.erase(itr);
@@ -417,8 +417,8 @@ int QQuickWorkerScriptEngine::registerWorkerScript(QQuickWorkerScript *owner)
void QQuickWorkerScriptEngine::removeWorkerScript(int id)
{
- const auto it = d->workers.find(id);
- if (it == d->workers.end())
+ const auto it = d->workers.constFind(id);
+ if (it == d->workers.cend())
return;
if (it->isT1()) {