From 45540a30dbd101db97e1b380e2550a117ec154a6 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Thu, 31 May 2012 15:50:06 +0200 Subject: [PATCH] QmlDebugging: Save few cycles Change-Id: I6d094605e3983128b844f2156909b98a4016509f Reviewed-by: hjk --- .../debugger/qml/qmlinspectoragent.cpp | 32 +++++++++++-------- .../debugger/qml/qmlv8debuggerclient.cpp | 14 ++++---- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index a8dedab3b2f..3c5692f10e4 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -228,9 +228,10 @@ ObjectReference QmlInspectorAgent::objectForName( { if (!objectId.isEmpty() && objectId[0].isLower()) { QHashIterator iter(m_debugIdToIname); + const WatchHandler *watchHandler = m_debuggerEngine->watchHandler(); while (iter.hasNext()) { iter.next(); - const WatchData *wd = m_debuggerEngine->watchHandler()->findData(iter.value()); + const WatchData *wd = watchHandler->findData(iter.value()); if (wd && wd->name == objectId) return ObjectReference(iter.key()); } @@ -286,8 +287,9 @@ int QmlInspectorAgent::objectIdForLocation( QHash QmlInspectorAgent::rootObjectIds() const { QHash rIds; + const WatchHandler *watchHandler = m_debuggerEngine->watchHandler(); foreach (const QByteArray &in, m_debugIdToIname) { - const WatchData *data = m_debuggerEngine->watchHandler()->findData(in); + const WatchData *data = watchHandler->findData(in); if (!data) continue; int debugId = data->id; @@ -482,13 +484,14 @@ void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyNa { const QByteArray iname = m_debugIdToIname.value(debugId) + ".[properties]." + propertyName; - const WatchData *data = m_debuggerEngine->watchHandler()->findData(iname); + WatchHandler *watchHandler = m_debuggerEngine->watchHandler(); + const WatchData *data = watchHandler->findData(iname); if (debug) qDebug() << __FUNCTION__ << "(" << debugId << ")" << iname <watchHandler()->insertData(d); + watchHandler->insertData(d); } } @@ -673,9 +676,10 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object) m_newObjectsCreated = false; m_objectStack.clear(); + WatchHandler *watchHandler = m_debuggerEngine->watchHandler(); if (debug) timeElapsed.start(); - m_debuggerEngine->watchHandler()->insertData(watchData); + watchHandler->insertData(watchData); if (debug) qDebug() << __FUNCTION__ << "Time: Insertion took " << timeElapsed.elapsed() << " ms"; @@ -687,7 +691,7 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object) QByteArray iname = m_debugIdToIname.value(last.debugId()); if (debug) qDebug() << " selecting" << iname << "in tree"; - m_debuggerEngine->watchHandler()->setCurrentItem(iname); + watchHandler->setCurrentItem(iname); m_objectToSelect = -1; } } @@ -783,16 +787,16 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, addObjectWatch(objWatch.id); } - // To improve performance, we do not insert data for items - // that have not been previously queried when the object tree is refreshed. - if (!m_debuggerEngine->watchHandler()->isExpandedIName(objIname) && m_newObjectsCreated) - append = false; - - if (!m_debuggerEngine->watchHandler()->isExpandedIName(objIname) - && obj.needsMoreData()) { + if (!m_debuggerEngine->watchHandler()->isExpandedIName(objIname)) { // we don't know the children yet. Not adding the 'properties' // element makes sure we're queried on expansion. - return list; + if (obj.needsMoreData()) + return list; + + // To improve performance, we do not insert data for items + // that have not been previously queried when the object tree is refreshed. + if (m_newObjectsCreated) + append = false; } // properties diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp index 8d35db37c62..8b58568b644 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp +++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp @@ -1798,6 +1798,7 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con // "running" : // "success" : true // } + WatchHandler *watchHandler = d->engine->watchHandler(); if (d->updateLocalsAndWatchers.contains(sequence)) { d->updateLocalsAndWatchers.removeOne(sequence); //Update the locals @@ -1805,7 +1806,7 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con d->scope(index); //Also update "this" QByteArray iname("local.this"); - const WatchData *parent = d->engine->watchHandler()->findData(iname); + const WatchData *parent = watchHandler->findData(iname); d->localsAndWatchers.insertMulti(parent->id, iname); d->lookup(QList() << parent->id); @@ -1828,10 +1829,10 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con WatchData data; //Do we have request to evaluate a local? if (exp.startsWith("local.")) { - const WatchData *watch = d->engine->watchHandler()->findData(exp.toLatin1()); + const WatchData *watch = watchHandler->findData(exp.toLatin1()); watchDataList << createWatchDataList(watch, body.properties, refsVal); } else { - QByteArray iname = d->engine->watchHandler()->watcherName(exp.toLatin1()); + QByteArray iname = watchHandler->watcherName(exp.toLatin1()); SDEBUG(QString(iname)); data.exp = exp.toLatin1(); @@ -1849,7 +1850,7 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con watchDataList << data << createWatchDataList(&data, body.properties, refsVal); } //Insert the newly evaluated expression to the Watchers Window - d->engine->watchHandler()->insertData(watchDataList); + watchHandler->insertData(watchDataList); } } } @@ -1918,6 +1919,7 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const QList watchDataList; QStringList handlesList = body.keys(); + WatchHandler *watchHandler = d->engine->watchHandler(); foreach (const QString &handle, handlesList) { QmlV8ObjectData bodyObjectData = d->extractData( body.value(handle), refsVal); @@ -1926,7 +1928,7 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const if (prepend.startsWith("local.") || prepend.startsWith("watch.")) { //Data for expanded local/watch //Could be an object or function - const WatchData *parent = d->engine->watchHandler()->findData(prepend); + const WatchData *parent = watchHandler->findData(prepend); watchDataList << createWatchDataList(parent, bodyObjectData.properties, refsVal); } else { //rest @@ -1945,7 +1947,7 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const } } - d->engine->watchHandler()->insertData(watchDataList); + watchHandler->insertData(watchDataList); } QList QmlV8DebuggerClient::createWatchDataList(const WatchData *parent,