diff options
| author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2024-04-22 18:16:24 +0300 |
|---|---|---|
| committer | Vladimir Belyavsky <belyavskyv@gmail.com> | 2024-04-22 20:26:47 +0000 |
| commit | 19b09affee8698f80d386e3b286753974f6bf10a (patch) | |
| tree | 9e4d147a36ba22308ad397b455f29478edbe032e /src/qml/jsruntime/qv4engine.cpp | |
| parent | 7b463868de47c5f08f086e9508cb4b41a310f268 (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/qml/jsruntime/qv4engine.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index acf6132799..d09dcced19 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -2172,15 +2172,15 @@ ExecutionEngine::Module ExecutionEngine::moduleForUrl( ExecutionEngine::Module ExecutionEngine::loadModule(const QUrl &url, const ExecutableCompilationUnit *referrer) { - const auto nativeModule = nativeModules.find(url); - if (nativeModule != nativeModules.end()) + const auto nativeModule = nativeModules.constFind(url); + if (nativeModule != nativeModules.cend()) return Module { nullptr, *nativeModule }; const QUrl resolved = referrer ? referrer->finalUrl().resolved(QQmlTypeLoader::normalize(url)) : QQmlTypeLoader::normalize(url); - auto existingModule = m_compilationUnits.find(resolved); - if (existingModule != m_compilationUnits.end()) + auto existingModule = m_compilationUnits.constFind(resolved); + if (existingModule != m_compilationUnits.cend()) return Module { *existingModule, nullptr }; auto newModule = compileModule(resolved); @@ -2191,8 +2191,8 @@ ExecutionEngine::Module ExecutionEngine::loadModule(const QUrl &url, const Execu QV4::Value *ExecutionEngine::registerNativeModule(const QUrl &url, const QV4::Value &module) { - const auto existingModule = nativeModules.find(url); - if (existingModule != nativeModules.end()) + const auto existingModule = nativeModules.constFind(url); + if (existingModule != nativeModules.cend()) return nullptr; QV4::Value *val = this->memoryManager->m_persistentValues->allocate(); |
