From 19b09affee8698f80d386e3b286753974f6bf10a Mon Sep 17 00:00:00 2001 From: Vladimir Belyavsky Date: Mon, 22 Apr 2024 18:16:24 +0300 Subject: 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 --- src/qmlworkerscript/qquickworkerscript.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qmlworkerscript/qquickworkerscript.cpp') 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(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()) { -- cgit v1.2.3