diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-08-12 14:19:33 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-08-26 12:40:37 +0000 |
commit | 31a2cbbbc2dcf7d87a4b90c90c193e09e9676d6c (patch) | |
tree | b122e5ac93f6577ad7d39ec89faae2f2bb9562e8 /src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp | |
parent | 0445f31a6fae37aa4f6b92978ff58b0f2848d36b (diff) |
Plugins: replace 'foreach' with 'range for'
Mark some local variables as const to prevent detach()'ing.
Use qAsConst where is not possible mark as const.
If a container is changed in a loop's body, just make copy
like 'foreach'.
Change-Id: Ic453a688a9edf8a864d47f6e3a605164508a027c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index dba2fd3cc3..4a82ae004f 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -92,7 +92,7 @@ void QQmlProfilerServiceImpl::dataReady(QQmlAbstractProfilerAdapter *profiler) m_startTimes.insert(0, profiler); if (dataComplete) { QList<QJSEngine *> enginesToRelease; - foreach (QJSEngine *engine, m_stoppingEngines) { + for (QJSEngine *engine : qAsConst(m_stoppingEngines)) { foreach (QQmlAbstractProfilerAdapter *engineProfiler, m_engineProfilers.values(engine)) { if (m_startTimes.values().contains(engineProfiler)) { enginesToRelease.append(engine); @@ -101,7 +101,7 @@ void QQmlProfilerServiceImpl::dataReady(QQmlAbstractProfilerAdapter *profiler) } } sendMessages(); - foreach (QJSEngine *engine, enginesToRelease) { + for (QJSEngine *engine : qAsConst(enginesToRelease)) { m_stoppingEngines.removeOne(engine); emit detachedFromEngine(engine); } @@ -183,7 +183,7 @@ void QQmlProfilerServiceImpl::addGlobalProfiler(QQmlAbstractProfilerAdapter *pro // Global profilers are started whenever any engine profiler is started and stopped when // all engine profilers are stopped. quint64 features = 0; - foreach (QQmlAbstractProfilerAdapter *engineProfiler, m_engineProfilers) + for (QQmlAbstractProfilerAdapter *engineProfiler : qAsConst(m_engineProfilers)) features |= engineProfiler->features(); if (features != 0) @@ -249,12 +249,12 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features startedAny = true; } } - foreach (QJSEngine *profiledEngine, engines) + for (QJSEngine *profiledEngine : qAsConst(engines)) d << idForObject(profiledEngine); } if (startedAny) { - foreach (QQmlAbstractProfilerAdapter *profiler, m_globalProfilers) { + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) { if (!profiler->isRunning()) profiler->startProfiling(features); } @@ -294,7 +294,7 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine) if (stopping.isEmpty()) return; - foreach (QQmlAbstractProfilerAdapter *profiler, m_globalProfilers) { + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) { if (!profiler->isRunning()) continue; m_startTimes.insert(-1, profiler); @@ -308,10 +308,10 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine) emit stopFlushTimer(); m_waitingForStop = true; - foreach (QQmlAbstractProfilerAdapter *profiler, reporting) + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting)) profiler->reportData(m_useMessageTypes); - foreach (QQmlAbstractProfilerAdapter *profiler, stopping) + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(stopping)) profiler->stopProfiling(); } @@ -327,7 +327,7 @@ void QQmlProfilerServiceImpl::sendMessages() traceEnd << m_timer.nsecsElapsed() << (int)Event << (int)EndTrace; QSet<QJSEngine *> seen; - foreach (QQmlAbstractProfilerAdapter *profiler, m_startTimes) { + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_startTimes)) { for (QMultiHash<QJSEngine *, QQmlAbstractProfilerAdapter *>::iterator i(m_engineProfilers.begin()); i != m_engineProfilers.end(); ++i) { if (i.value() == profiler && !seen.contains(i.key())) { @@ -367,7 +367,7 @@ void QQmlProfilerServiceImpl::sendMessages() emit messagesToClient(name(), messages); // Restart flushing if any profilers are still running - foreach (const QQmlAbstractProfilerAdapter *profiler, m_engineProfilers) { + for (const QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) { if (profiler->isRunning()) { emit startFlushTimer(); break; @@ -438,21 +438,21 @@ void QQmlProfilerServiceImpl::flush() QMutexLocker lock(&m_configMutex); QList<QQmlAbstractProfilerAdapter *> reporting; - foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers) { + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) { if (profiler->isRunning()) { m_startTimes.insert(-1, profiler); reporting.append(profiler); } } - foreach (QQmlAbstractProfilerAdapter *profiler, m_globalProfilers) { + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) { if (profiler->isRunning()) { m_startTimes.insert(-1, profiler); reporting.append(profiler); } } - foreach (QQmlAbstractProfilerAdapter *profiler, reporting) + for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting)) profiler->reportData(m_useMessageTypes); } |