[PATCH/RFC] On the iconview and the speed of directory listing.

Maks Orlovich mo002j at mail.rochester.edu
Sun May 25 16:11:05 CEST 2003


> within a single KIconViewItem::calcRect()). The other option, of course, is
> to try to figure out why multiple updateItemContainer calls are so slow.

The reason is that once an item has been inserted once, calling 
QIconView::updateItemContainer() will call removeRef() on a QPtrList 
with lots and lots of items (I suspect nearly all, but I am not sure, that 
class could use a few overly verbose comments; this might mean KIconView is 
going quadraric, which would explain the horrible times); this makes me think 
that the data structure choice is inappropriate, but that's probably not for 
me to try to figure out how to fix that. At any rate, for the case of 
creating new items, the patch below does wonders (getting us into the 7-10 
second range without modifying KIconView), but it's really just a 
special-case fast path. 

-Maks

--- iconview/qiconview.cpp      16 May 2003 13:02:38 -0000      1.47
+++ iconview/qiconview.cpp      25 May 2003 19:06:15 -0000
@@ -6016,11 +6016,19 @@ void QIconView::updateItemContainer( QIc
        return;

     if ( item->d->container1 && d->firstContainer ) {
-       item->d->container1->items.removeRef( item );
+       //Special-case checking of the last item, since this may be
+       //called a few times for the same item.
+       if (item->d->container1->items.last() == item)
+           item->d->container1->items.removeLast();
+       else
+           item->d->container1->items.removeRef( item );
     }
     item->d->container1 = 0;
     if ( item->d->container2 && d->firstContainer ) {
-       item->d->container2->items.removeRef( item );
+       if (item->d->container2->items.last() == item)
+           item->d->container2->items.removeLast();
+       else
+           item->d->container2->items.removeRef( item );
     }
     item->d->container2 = 0;





More information about the Kde-optimize mailing list