Hi,
kdiff3 is a tool i regularly use to compare folder hierarchies, but what always troubled me a bit was the performance issues when traversing the tree or showing/hiding a subset of items (equal, orphans in A/B).. when i did a valgrind --tool=callgrind run on it yesterday i finally saw where all this time is spent - within the QTreeWidget::isItemHidden function! That is maintaining a list of hidden items and traverses that each and every time to find out wheter an individual item actually is hidden. Comparing two folder hierarchies with a total of ~8000 items thus results in over 150 million iterations within that loop! The simple hack which is attached obviously cut that down massively, but i'm not sure wether it might break any functionality that is provided by iterating over that list.. Does it?
rgds marcel.


--
  "Obstacles are those frightful things you see when you take
   your eyes off your goal."         -- Henry Ford (1863-1947)

   Change the world! Vote: http://hfopi.org/vote-future
--- ./src/gui/itemviews/qtreewidget.h.orig      2009-01-29 02:00:43.000000000 
+0100
+++ ./src/gui/itemviews/qtreewidget.h   2009-02-02 01:52:36.841835741 +0100
@@ -202,6 +202,8 @@
 protected:
     void emitDataChanged();
 
+    bool hideFlag;
+
 private:
     void sortChildren(int column, Qt::SortOrder order, bool climb);
     QVariant childrenCheckState(int column) const;
@@ -395,7 +397,7 @@
 { return (view ? view->isItemSelected(this) : false); }
 
 inline void QTreeWidgetItem::setHidden(bool ahide)
-{ if (view) view->setItemHidden(this, ahide); }
+{ if (view) hideFlag = ahide; }
 
 inline bool QTreeWidgetItem::isHidden() const
 { return (view ? view->isItemHidden(this) : false); }
--- ./src/gui/itemviews/qtreewidget.cpp.orig    2009-01-29 02:00:43.000000000 
+0100
+++ ./src/gui/itemviews/qtreewidget.cpp 2009-02-02 01:54:43.106085102 +0100
@@ -1302,6 +1302,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
 }
 
 
@@ -1321,6 +1322,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
     for (int i = 0; i < strings.count(); ++i)
         setText(i, strings.at(i));
 }
@@ -1342,6 +1344,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
     if (view && view->model()) {
         QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
         model->rootItem->addChild(this);
@@ -1367,6 +1370,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
     for (int i = 0; i < strings.count(); ++i)
         setText(i, strings.at(i));
     if (view && view->model()) {
@@ -1392,6 +1396,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
     if (view) {
         QTreeModel *model = qobject_cast<QTreeModel*>(view->model());
         if (model) {
@@ -1415,6 +1420,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
     if (parent)
         parent->addChild(this);
 }
@@ -1433,6 +1439,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
     for (int i = 0; i < strings.count(); ++i)
         setText(i, strings.at(i));
     if (parent)
@@ -1455,6 +1462,7 @@
                 |Qt::ItemIsDragEnabled
                 |Qt::ItemIsDropEnabled)
 {
+    hideFlag = false;
     if (parent) {
         int i = parent->children.indexOf(after) + 1;
         parent->insertChild(i, this);
@@ -1838,6 +1846,7 @@
       d(new QTreeWidgetItemPrivate(this)), par(0),
       itemFlags(other.itemFlags)
 {
+    hideFlag = false;
     d->display = other.d->display;
 }
 
@@ -3048,6 +3057,7 @@
     Q_D(const QTreeWidget);
     if (item == d->model()->headerItem)
         return header()->isHidden();
+    return (item->hideFlag);
     if (d->hiddenIndexes.isEmpty())
         return false;
     foreach (const QPersistentModelIndex &idx, d->hiddenIndexes)
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to