[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kio/kio
From: Michael Brade <brade () kde ! org>
Date: 2005-03-27 11:39:52
Message-ID: 20050327113952.CE77B3C0 () office ! kde ! org
[Download RAW message or body]
CVS commit by brade:
Optimize KDirLister updates: Reduce the new/delete operations in slotUpdateResult
to the minimum by re-using already allocated memory. It makes updates about 7-8%
faster.
I had a very brief but inspiring chat with Till at FOSDEM, who suggested to
allocate some memory and create/delete all KFileItems in there, which brought me
to the idea of re-using the KFileItems themselves. Thanks!
M +12 -3 kdirlister.cpp 1.194
--- kdelibs/kio/kio/kdirlister.cpp #1.193:1.194
@@ -1492,5 +1492,5 @@ void KDirListerCache::slotUpdateResult(
static const QString& dotdot = KGlobal::staticQString("..");
- KFileItem *item, *tmp;
+ KFileItem *item = 0, *tmp;
QValueList<KIO::UDSEntry> buf = jobs[job];
@@ -1533,5 +1533,8 @@ void KDirListerCache::slotUpdateResult(
// Form the complete url
+ if ( !item )
item = new KFileItem( *it, jobUrl, delayedMimeTypes, true );
+ else
+ item->setUDSEntry( *it, jobUrl, delayedMimeTypes, true );
QString url = item->url().url();
@@ -1555,5 +1558,4 @@ void KDirListerCache::slotUpdateResult(
kdl->addRefreshItem( tmp );
}
- delete item; // gmbl, this is the most often case... IMPORTANT TODO: speed it up somehow!
}
else // this is a new file
@@ -1561,4 +1563,5 @@ void KDirListerCache::slotUpdateResult(
//kdDebug(7004) << "slotUpdateResult: new file: " << name << endl;
+ item = new KFileItem( *it, jobUrl, delayedMimeTypes, true );
item->mark();
dir->lstItems->append( item );
@@ -1566,7 +1569,13 @@ void KDirListerCache::slotUpdateResult(
for ( kdl = listers->first(); kdl; kdl = listers->next() )
kdl->addNewItem( item );
+
+ // item used, we need a new one for the next iteration
+ item = 0;
}
}
+ if ( item )
+ delete item;
+
jobs.remove( job );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic