From 33758b47f362a0f5c77bfd98b7eec9ff80203662 Mon Sep 17 00:00:00 2001 From: PeterLValve Date: Tue, 18 Mar 2014 13:31:29 -0700 Subject: [PATCH] UI: Improve processing time of vogleditor_apicalltreeitem by pre-calculating the local row index * This value will have to get updated if new rows (API calls) can be added / removed, which may undo this optimization, but when investigating a slowness during searching, the code was often found in this function. --- src/vogleditor/vogleditor_apicalltreeitem.cpp | 17 +++++++++-------- src/vogleditor/vogleditor_apicalltreeitem.h | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/vogleditor/vogleditor_apicalltreeitem.cpp b/src/vogleditor/vogleditor_apicalltreeitem.cpp index 32ff10a..3fd2d7f 100644 --- a/src/vogleditor/vogleditor_apicalltreeitem.cpp +++ b/src/vogleditor/vogleditor_apicalltreeitem.cpp @@ -35,7 +35,8 @@ vogleditor_apiCallTreeItem::vogleditor_apiCallTreeItem(vogleditor_QApiCallTreeMo : m_parentItem(NULL), m_pApiCallItem(NULL), m_pFrameItem(NULL), - m_pModel(pModel) + m_pModel(pModel), + m_localRowIndex(0) { m_columnData[VOGL_ACTC_APICALL] = "API Call"; m_columnData[VOGL_ACTC_INDEX] = "Index"; @@ -51,7 +52,8 @@ vogleditor_apiCallTreeItem::vogleditor_apiCallTreeItem(vogleditor_frameItem* fra : m_parentItem(parent), m_pApiCallItem(NULL), m_pFrameItem(frameItem), - m_pModel(NULL) + m_pModel(NULL), + m_localRowIndex(0) { if (frameItem != NULL) { @@ -71,7 +73,8 @@ vogleditor_apiCallTreeItem::vogleditor_apiCallTreeItem(QString nodeText, vogledi : m_parentItem(parent), m_pApiCallItem(apiCallItem), m_pFrameItem(NULL), - m_pModel(NULL) + m_pModel(NULL), + m_localRowIndex(0) { m_columnData[VOGL_ACTC_APICALL] = nodeText; @@ -122,7 +125,8 @@ vogleditor_apiCallTreeItem* vogleditor_apiCallTreeItem::parent() const void vogleditor_apiCallTreeItem::appendChild(vogleditor_apiCallTreeItem* pChild) { - m_childItems.append(pChild); + pChild->m_localRowIndex = m_childItems.size(); + m_childItems.append(pChild); } int vogleditor_apiCallTreeItem::childCount() const @@ -252,8 +256,5 @@ QVariant vogleditor_apiCallTreeItem::columnData(int column, int role) const int vogleditor_apiCallTreeItem::row() const { // note, this is just the row within the current level of the hierarchy - if (m_parentItem) - return m_parentItem->m_childItems.indexOf(const_cast(this)); - - return 0; + return m_localRowIndex; } diff --git a/src/vogleditor/vogleditor_apicalltreeitem.h b/src/vogleditor/vogleditor_apicalltreeitem.h index 9957a72..b76b0e1 100644 --- a/src/vogleditor/vogleditor_apicalltreeitem.h +++ b/src/vogleditor/vogleditor_apicalltreeitem.h @@ -93,6 +93,7 @@ private: vogleditor_apiCallItem* m_pApiCallItem; vogleditor_frameItem* m_pFrameItem; vogleditor_QApiCallTreeModel* m_pModel; + int m_localRowIndex; }; #endif // VOGLEDITOR_APICALLTREEITEM_H -- 2.43.0