KIconLoader improvements: icon server

Aaron J. Seigo aseigo at kde.org
Tue Jun 14 23:43:46 CEST 2005


On Tuesday 14 June 2005 10:31, George Staikos wrote:
>   I was wondering about that too.  My random guess is that it has to do
> with an algorithmic problem inside the icon server.  That's just a guess
> though. :-)

looking through the patch there certainly is room for improvements, which 
likely will only show up with larger collections of icons... for instance, 
this:

void KIconServer::refIcons( QValueList< QCString > keys_P )
{
    if( keys_P.empty())
        return;
    for( QValueList< QCString >::ConstIterator it = keys_P.begin(); it != 
keys_P.end(); ++it )
    {
        if( icons.contains( *it ))
        {
            kdDebug( 179 ) << "increasing refcount: " << *it << endl;
            if( icons[ *it ].ref())
                --old_icons_count;
            continue;
        }
        kdWarning( 179 ) << "unknown icon in refIcons" << endl;
    }
    app_ref_deref( kapp->dcopClient()->senderId(), keys_P, true );
}

both contains and operator[] run a find on the red black tree. doing something 
like

	IconMap::iterator it = icons.find(*it);
	if (it != icons.end())
	{
		if ((*it).ref())
		{
			--old_icons_count;
		}
	}

should be more efficient. 

app_ref_deref calls KIconAppRef::ref or ::deref .. ::ref can cause a resize of 
the array, will do two qheapsorts, and iterates over every key with an inner 
loop iterating over the already ref'd keys. so as the number of icons grows, 
the time required there will not grow linearly.

i also noticed that while const_iterators are often used, the collection 
class's begin() and end() versus constBegin() and constEnd() are used. 

there's probably more in there, which is actually pretty good since is already 
performs better than cached icons it should be able to go even faster =)

-- 
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-optimize/attachments/20050614/237cc677/attachment.pgp


More information about the Kde-optimize mailing list