[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [patch] Preload popup menus for the desktop (3.5)
From:       Scott Wheeler <wheeler () kde ! org>
Date:       2006-04-04 23:42:50
Message-ID: 200604050142.50416.wheeler () kde ! org
[Download RAW message or body]

On Wednesday 05 April 2006 1:19, David Faure wrote:
> Hmm. I can't see how the plugins would be particularly slower than the rest
> of the popupmenu-setup code, they do the same kind of thing: creating
> actions and plugging them. Although arkplugin.cpp does a new KConfig each
> time which could easily be changed to a kstatic-deleted static KConfig *
> (but you said kconfig was fast).

I don't claim to understand it, but for me it's somewhat moot since we allow 
third parties to install stuff there and one poorly written service menu 
entry could make Konq / KDesktop suck without any clear link between the 
plugin and the sucking.

> Anyway you gave percentages in one mail and milliseconds in the next one
> so I'm a bit confused with the timing data :)

Well, the numbers that I'm getting are in ms, when I divide that by the total 
I get a percentage.  ;-)  If you actually want to see what I'm working with 
I've attached The Dirtiest Patch Ever (I'm not bothering to clean it up since 
it's just hacks to get numbers out.).  I've got another ugly one for 
componentfactory.h, but at least with this one, if you feel so compelled, you 
should be able to see if you get similar numbers.  A basic guide to the 
interesting stuff:

In setup():

pr_setup11 / pr_setup_popupservices7 - addPlugins()
pr_setup8 - DCOP and big loop mentioned in my last mail
pr_setup9 - KTrader
pr_setup3 - KSimpleConfig

In addPlugins():

pr_addplugins2 - KTrader
pr_addplugins5 - createInstanceFromLibrary<>()

I've just been testing these with Konq since it's easier to restart quickly.

-Scott

-- 
It may be true that you can't fool all the people all the time, but you can 
fool enough of them to rule a large country. 
--Will Durant

["instrumented" (text/x-diff)]

Index: konq_popupmenu.cc
===================================================================
--- konq_popupmenu.cc	(revision 526041)
+++ konq_popupmenu.cc	(working copy)
@@ -201,7 +201,9 @@
                               KNewMenu * newMenu,
                               QWidget * parentWidget,
                               bool showProperties )
-    : QPopupMenu( parentWidget, "konq_popupmenu" ), m_actions( actions ), \
m_ownActions( static_cast<QWidget *>( 0 ), "KonqPopupMenu::m_ownActions" ), \
m_pMenuNew( newMenu ), m_sViewURL(viewURL), m_lstItems(items), m_pManager(mgr) +    : \
QPopupMenu( parentWidget, "konq_popupmenu" ), m_actions( actions ), +      \
m_ownActions( static_cast<QWidget *>( 0 ), "KonqPopupMenu::m_ownActions" ), +      \
m_pMenuNew( newMenu ), m_sViewURL(viewURL), m_lstItems(items), m_pManager(mgr)  {
     KonqPopupFlags kpf = ( showProperties ? ShowProperties : IsLink ) | \
ShowNewWindow;  init(parentWidget, kpf, KParts::BrowserExtension::DefaultPopupItems);
@@ -214,7 +216,9 @@
                               QWidget * parentWidget,
                               KonqPopupFlags kpf,
                               KParts::BrowserExtension::PopupFlags flags)
-  : QPopupMenu( parentWidget, "konq_popupmenu" ), m_actions( actions ), \
m_ownActions( static_cast<QWidget *>( 0 ), "KonqPopupMenu::m_ownActions" ), \
m_pMenuNew( newMenu ), m_sViewURL(viewURL), m_lstItems(items), m_pManager(mgr) +  : \
QPopupMenu( parentWidget, "konq_popupmenu" ), m_actions( actions ), +    \
m_ownActions( static_cast<QWidget *>( 0 ), "KonqPopupMenu::m_ownActions" ), +    \
m_pMenuNew( newMenu ), m_sViewURL(viewURL), m_lstItems(items), m_pManager(mgr)  {
     init(parentWidget, kpf, flags);
 }
@@ -324,9 +328,43 @@
     return true;
 }
 
+#include <kprofilemethod.h>
 
+int pr_setup1 = 0;
+int pr_setup2 = 0;
+int pr_setup3 = 0;
+int pr_setup4 = 0;
+int pr_setup5 = 0;
+int pr_setup6 = 0;
+int pr_setup7 = 0;
+int pr_setup8 = 0;
+int pr_setup9 = 0;
+int pr_setup10 = 0;
+int pr_setup11 = 0;
+
+int pr_setup_service1 = 0;
+int pr_setup_service2 = 0;
+int pr_setup_service3 = 0;
+int pr_setup_service4 = 0;
+int pr_setup_service5 = 0;
+int pr_setup_service6 = 0;
+
+int pr_setup_popupservices1 = 0;
+int pr_setup_popupservices2 = 0;
+int pr_setup_popupservices3 = 0;
+int pr_setup_popupservices4 = 0;
+int pr_setup_popupservices5 = 0;
+int pr_setup_popupservices6 = 0;
+int pr_setup_popupservices7 = 0;
+int pr_setup_popupservices8 = 0;
+int pr_setup_popupservices9 = 0;
+int pr_setup_popupservices10 = 0;
+int pr_setup_popupservices11 = 0;
+
 void KonqPopupMenu::setup(KonqPopupFlags kpf)
 {
+    PROFILE_METHOD_BEGIN(pr_setup1);
+
     assert( m_lstItems.count() >= 1 );
 
     m_ownActions.setWidget( this );
@@ -350,7 +388,7 @@
     m_lstPopupURLs.clear();
     int id = 0;
     setFont(KGlobalSettings::menuFont());
-    m_pluginList.setAutoDelete( true );
+    /* m_pluginList.setAutoDelete( true ); */
     m_ownActions.setHighlightingEnabled( true );
 
     attrName = QString::fromLatin1( "name" );
@@ -362,6 +400,10 @@
     KURL url;
     KFileItemListIterator it ( m_lstItems );
     QStringList mimeTypeList;
+
+    PROFILE_METHOD_END(pr_setup1);
+    PROFILE_METHOD_BEGIN(pr_setup2);
+
     // Check whether all URLs are correct
     for ( ; it.current(); ++it )
     {
@@ -410,6 +452,10 @@
         if ( (*it)->mimetype().startsWith("media/") )
             mediaFiles = true;
     }
+
+    PROFILE_METHOD_END(pr_setup2);
+    PROFILE_METHOD_BEGIN(pr_setup3);
+
     url = m_sViewURL;
     url.cleanPath();
 
@@ -431,6 +477,10 @@
             sDeleting = false;
         }
     }
+
+    PROFILE_METHOD_END(pr_setup3);
+    PROFILE_METHOD_BEGIN(pr_setup4);
+
     const bool isSingleLocal = m_lstItems.count() == 1 && isLocal;
 
     m_info.m_Reading = sReading;
@@ -442,7 +492,8 @@
     // isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
     bool isCurrentTrash = ( m_lstItems.count() == 1 && bTrashIncluded ) || \
                isTrashLink;
     bool isIntoTrash = ( url.protocol() == "trash" || url.url().startsWith( \
                "system:/trash" ) ) && !isCurrentTrash; // trashed file, not trash:/ \
                itself
-    //kdDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << \
isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << \
bTrashIncluded << endl; +    //kdDebug() << "isLocal=" << isLocal << " url=" << url \
<< " isCurrentTrash=" << +    // isCurrentTrash << " isIntoTrash=" << isIntoTrash << \
" bTrashIncluded=" << bTrashIncluded << endl;  bool isSingleMedium = \
m_lstItems.count() == 1 && mediaFiles;  clear();
 
@@ -462,6 +513,9 @@
         kpf &= ~ShowProperties; // remove flag
     }
 
+    PROFILE_METHOD_END(pr_setup4);
+    PROFILE_METHOD_BEGIN(pr_setup5);
+
     // Either 'newview' is in the actions we're given (probably in the tabhandling \
                group)
     // or we need to insert it ourselves (e.g. for kdesktop). In the first case, \
actNewWindow must remain 0.  if ( ((kpf & ShowNewWindow) != 0) && sReading )
@@ -582,6 +636,7 @@
     if (d->m_itemFlags & KParts::BrowserExtension::ShowTextSelectionItems) {
       addMerge( 0 );
       m_factory->addClient( this );
+      PROFILE_METHOD_END(pr_setup5);
       return;
     }
 
@@ -613,16 +668,21 @@
             addGroup( "linkactions" );
     }
 
+
+    PROFILE_METHOD_END(pr_setup5);
+    PROFILE_METHOD_BEGIN(pr_setup6);
+
     //////////////////////////////////////////////////////
 
-    PopupServices s;
+    PopupServices popupServices;
     KURL urlForServiceMenu( m_lstItems.first()->url() );
 
     // 1 - Look for builtin and user-defined services
     if ( m_sMimeType == "application/x-desktop" && isSingleLocal ) // .desktop file
     {
+	kdDebug() << "pr_ !!!" << endl;
         // get builtin services, like mount/unmount
-        s.builtin = KDEDesktopMimeType::builtinServices( m_lstItems.first()->url() \
); +        popupServices.builtin = KDEDesktopMimeType::builtinServices( \
m_lstItems.first()->url() );  const QString path = m_lstItems.first()->url().path();
         KSimpleConfig cfg( path, true );
         cfg.setDesktopGroup();
@@ -633,12 +693,15 @@
            // TODO: Do we want to make all the actions apply on the target
            // of the .desktop file instead of the .desktop file itself?
         }
-        ServiceList* list = s.selectList( priority, submenuName );
+        ServiceList* list = popupServices.selectList( priority, submenuName );
         (*list) = KDEDesktopMimeType::userDefinedServices( path, cfg, \
url.isLocalFile() );  }
 
+    PROFILE_METHOD_END(pr_setup6);
+
     if ( sReading )
     {
+	PROFILE_METHOD_BEGIN(pr_setup7);
 
         // 2 - Look for "servicesmenus" bindings (konqueror-specific user-defined \
services)  
@@ -653,12 +716,20 @@
             {
                 const QString priority = cfg.readEntry("X-KDE-Priority");
                 const QString submenuName = cfg.readEntry( "X-KDE-Submenu" );
-                ServiceList* list = s.selectList( priority, submenuName );
+                ServiceList* list = popupServices.selectList( priority, submenuName \
                );
                 (*list) += KDEDesktopMimeType::userDefinedServices( \
dotDirectoryFile, cfg, true );  }
         }
 
+	PROFILE_METHOD_END(pr_setup7);
+	PROFILE_METHOD_BEGIN(pr_setup8);
+
+	PROFILE_METHOD_BEGIN(pr_setup_service1);
+
         QStringList dirs = KGlobal::dirs()->findDirs( "data", \
"konqueror/servicemenus/" ); +
+	PROFILE_METHOD_END(pr_setup_service1);
+
         QStringList::ConstIterator dIt = dirs.begin();
         QStringList::ConstIterator dEnd = dirs.end();
 
@@ -672,7 +743,15 @@
 
             for (; eIt != eEnd; ++eIt )
             {
-                KSimpleConfig cfg( *dIt + *eIt, true );
+/*
+		PROFILE_METHOD_END(pr_setup_service2);
+		PROFILE_METHOD_END(pr_setup_service3);
+		PROFILE_METHOD_END(pr_setup_service4);
+		PROFILE_METHOD_END(pr_setup_service5);
+		PROFILE_METHOD_END(pr_setup_service6);
+*/
+
+		KSimpleConfig cfg( *dIt + *eIt, true );
                 cfg.setDesktopGroup();
 
                 if (!KIOSKAuthorizedAction(cfg))
@@ -680,12 +759,20 @@
                     continue;
                 }
 
+/*
+		PROFILE_METHOD_BEGIN(pr_setup_service2);
+*/
+
                 if ( cfg.hasKey( "X-KDE-ShowIfRunning" ) )
                 {
                     const QString app = cfg.readEntry( "X-KDE-ShowIfRunning" );
                     if ( !kapp->dcopClient()->isApplicationRegistered( app.utf8() ) \
)  continue;
                 }
+/*
+		PROFILE_METHOD_END(pr_setup_service2);
+		PROFILE_METHOD_BEGIN(pr_setup_service3);
+*/
 		if ( cfg.hasKey( "X-KDE-ShowIfDcopCall" ) )
 		{
 		    QString dcopcall = cfg.readEntry( "X-KDE-ShowIfDcopCall" );
@@ -703,7 +790,8 @@
 		    QCString object =    dcopcall.section(' ', 1,-2).utf8();
 		    QString function =  dcopcall.section(' ', -1);
 		    if(!function.endsWith("(KURL::List)")) {
-			kdWarning() << "Desktop file " << *eIt << " contains an invalid \
X-KDE-ShowIfDcopCall - the function must take the exact parameter (KURL::List) and \
must be specified." << endl; +			kdWarning() << "Desktop file " << *eIt << " contains \
an invalid X-KDE-ShowIfDcopCall "  +				    << "- the function must take the exact \
parameter (KURL::List) and must be specified." << endl;  continue; //Be safe.
 		    }
 
@@ -715,6 +803,10 @@
 			continue;
 
 		}
+/*
+		PROFILE_METHOD_END(pr_setup_service3);
+		PROFILE_METHOD_BEGIN(pr_setup_service4);
+*/
                 if ( cfg.hasKey( "X-KDE-Protocol" ) )
                 {
                     const QString protocol = cfg.readEntry( "X-KDE-Protocol" );
@@ -728,13 +820,20 @@
                     // One might want a servicemenu for trash.desktop itself though.
                     continue;
                 }
-
+/*
+		PROFILE_METHOD_END(pr_setup_service4);
+		PROFILE_METHOD_BEGIN(pr_setup_service5);
+*/
                 if ( cfg.hasKey( "X-KDE-Require" ) )
                 {
                     const QStringList capabilities = cfg.readListEntry( \
"X-KDE-Require" );  if ( capabilities.contains( "Write" ) && !sWriting )
                         continue;
                 }
+/*
+		PROFILE_METHOD_END(pr_setup_service5);
+		PROFILE_METHOD_BEGIN(pr_setup_service6);
+*/
                 if ( (cfg.hasKey( "Actions" ) || cfg.hasKey( "X-KDE-GetActionMenu") \
) && cfg.hasKey( "ServiceTypes" ) )  {
                     const QStringList types = cfg.readListEntry( "ServiceTypes" );
@@ -793,19 +892,29 @@
                         const QString priority = cfg.readEntry("X-KDE-Priority");
                         const QString submenuName = cfg.readEntry( "X-KDE-Submenu" \
);  
-                        ServiceList* list = s.selectList( priority, submenuName );
+                        ServiceList* list = popupServices.selectList( priority, \
                submenuName );
                         (*list) += KDEDesktopMimeType::userDefinedServices( *dIt + \
*eIt, cfg, url.isLocalFile(), m_lstPopupURLs );  }
 
                 }
             }
+/*
+	    PROFILE_METHOD_END(pr_setup_service2);
+	    PROFILE_METHOD_END(pr_setup_service3);
+	    PROFILE_METHOD_END(pr_setup_service4);
+	    PROFILE_METHOD_END(pr_setup_service5);
+	    PROFILE_METHOD_END(pr_setup_service6);
+*/
         }
+	PROFILE_METHOD_END(pr_setup8);
+	PROFILE_METHOD_BEGIN(pr_setup9);
 
         KTrader::OfferList offers;
 
         if (kapp->authorizeKAction("openwith"))
         {
-            QString constraint = "Type == 'Application' and DesktopEntryName != \
'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != \
'kfmclient_html'"; +            QString constraint = "Type == 'Application' and \
DesktopEntryName != 'kfmclient' and " +		"DesktopEntryName != 'kfmclient_dir' and \
DesktopEntryName != 'kfmclient_html'";  QString subConstraint = " and '%1' in \
ServiceTypes";  
             QStringList::ConstIterator it = mimeTypeList.begin();
@@ -821,6 +930,9 @@
             offers = KTrader::self()->query( first, constraint );
         }
 
+	PROFILE_METHOD_END(pr_setup9);
+	PROFILE_METHOD_BEGIN(pr_setup10);
+
         //// Ok, we have everything, now insert
 
         m_mapPopup.clear();
@@ -891,13 +1003,18 @@
 
         }
         addGroup( "preview" );
+
+	PROFILE_METHOD_END(pr_setup10);
     }
 
+    PROFILE_METHOD_BEGIN(pr_setup11);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices1);
+
     // Second block, builtin + user
     QDomElement actionMenu = m_menuElement;
     int userItemCount = 0;
-    if (s.user.count() + s.userSubmenus.count() +
-        s.userPriority.count() + s.userPrioritySubmenus.count() > 1)
+    if (popupServices.user.count() + popupServices.userSubmenus.count() +
+        popupServices.userPriority.count() + \
popupServices.userPrioritySubmenus.count() > 1)  {
         // we have more than one item, so let's make a submenu
         actionMenu = m_doc.createElement( "menu" );
@@ -908,35 +1025,56 @@
         text.appendChild( m_doc.createTextNode( i18n("Ac&tions") ) );
     }
 
-    userItemCount += insertServicesSubmenus(s.userPrioritySubmenus, actionMenu, \
                false);
-    userItemCount += insertServices(s.userPriority, actionMenu, false);
+    PROFILE_METHOD_END(pr_setup_popupservices1);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices2);
 
+    userItemCount += insertServicesSubmenus(popupServices.userPrioritySubmenus, \
actionMenu, false); +    userItemCount += insertServices(popupServices.userPriority, \
actionMenu, false); +
+    PROFILE_METHOD_END(pr_setup_popupservices2);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices3);
+
     // see if we need to put a separator between our priority items and our regular \
items  if (userItemCount > 0 &&
-        (s.user.count() > 0 ||
-         s.userSubmenus.count() > 0 ||
-         s.builtin.count() > 0) &&
+        (popupServices.user.count() > 0 ||
+         popupServices.userSubmenus.count() > 0 ||
+         popupServices.builtin.count() > 0) &&
          actionMenu.lastChild().toElement().tagName().lower() != "separator")
     {
         QDomElement separator = m_doc.createElement( "separator" );
         actionMenu.appendChild(separator);
     }
 
-    userItemCount += insertServicesSubmenus(s.userSubmenus, actionMenu, false);
-    userItemCount += insertServices(s.user, actionMenu, false);
-    userItemCount += insertServices(s.builtin, m_menuElement, true);
+    PROFILE_METHOD_END(pr_setup_popupservices3);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices4);
 
-    userItemCount += insertServicesSubmenus(s.userToplevelSubmenus, m_menuElement, \
                false);
-    userItemCount += insertServices(s.userToplevel, m_menuElement, false);
+    userItemCount += insertServicesSubmenus(popupServices.userSubmenus, actionMenu, \
false); +    userItemCount += insertServices(popupServices.user, actionMenu, false);
+    userItemCount += insertServices(popupServices.builtin, m_menuElement, true);
 
+    PROFILE_METHOD_END(pr_setup_popupservices4);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices5);
+
+    userItemCount += insertServicesSubmenus(popupServices.userToplevelSubmenus, \
m_menuElement, false); +    userItemCount += \
insertServices(popupServices.userToplevel, m_menuElement, false); +
+    PROFILE_METHOD_END(pr_setup_popupservices5);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices6);
+
     if ( userItemCount > 0 )
     {
         addPendingSeparator();
     }
 
+    PROFILE_METHOD_END(pr_setup_popupservices6);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices7);
+
     if ( !isCurrentTrash && !isIntoTrash && !mediaFiles && sReading )
         addPlugins(); // now it's time to add plugins
 
+    PROFILE_METHOD_END(pr_setup_popupservices7);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices8);
+
     if ( KPropertiesDialog::canDisplay( m_lstItems ) && (kpf & ShowProperties) )
     {
         act = new KAction( i18n( "&Properties" ), 0, this, SLOT( \
slotPopupProperties() ), @@ -944,10 +1082,16 @@
         addAction( act );
     }
 
+    PROFILE_METHOD_END(pr_setup_popupservices8);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices9);
+
     while ( !m_menuElement.lastChild().isNull() &&
             m_menuElement.lastChild().toElement().tagName().lower() == "separator" )
         m_menuElement.removeChild( m_menuElement.lastChild() );
 
+    PROFILE_METHOD_END(pr_setup_popupservices9);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices10);
+
     if ( isDirectory && isLocal )
     {
         if ( KFileShare::authorization() == KFileShare::Authorized )
@@ -959,10 +1103,46 @@
         }
     }
 
+    PROFILE_METHOD_END(pr_setup_popupservices10);
+    PROFILE_METHOD_BEGIN(pr_setup_popupservices11);
+
     addMerge( 0 );
     //kdDebug() << k_funcinfo << domDocument().toString() << endl;
 
     m_factory->addClient( this );
+
+    PROFILE_METHOD_END(pr_setup11);
+
+    PROFILE_METHOD_PRINT(pr_setup1, "pr_setup1");
+    PROFILE_METHOD_PRINT(pr_setup2, "pr_setup2");
+    PROFILE_METHOD_PRINT(pr_setup3, "pr_setup3");
+    PROFILE_METHOD_PRINT(pr_setup4, "pr_setup4");
+    PROFILE_METHOD_PRINT(pr_setup5, "pr_setup5");
+    PROFILE_METHOD_PRINT(pr_setup6, "pr_setup6");
+    PROFILE_METHOD_PRINT(pr_setup7, "pr_setup7");
+    PROFILE_METHOD_PRINT(pr_setup8, "pr_setup8");
+    PROFILE_METHOD_PRINT(pr_setup9, "pr_setup9");
+    PROFILE_METHOD_PRINT(pr_setup10, "pr_setup10");
+    PROFILE_METHOD_PRINT(pr_setup11, "pr_setup11");
+
+    PROFILE_METHOD_PRINT(pr_setup_service1, "pr_setup_service1");
+    PROFILE_METHOD_PRINT(pr_setup_service2, "pr_setup_service2");
+    PROFILE_METHOD_PRINT(pr_setup_service3, "pr_setup_service3");
+    PROFILE_METHOD_PRINT(pr_setup_service4, "pr_setup_service4");
+    PROFILE_METHOD_PRINT(pr_setup_service5, "pr_setup_service5");
+    PROFILE_METHOD_PRINT(pr_setup_service6, "pr_setup_service6");
+
+    PROFILE_METHOD_PRINT(pr_setup_popupservices1, "pr_setup_popupservices1");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices2, "pr_setup_popupservices2");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices3, "pr_setup_popupservices3");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices4, "pr_setup_popupservices4");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices5, "pr_setup_popupservices5");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices6, "pr_setup_popupservices6");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices7, "pr_setup_popupservices7");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices8, "pr_setup_popupservices8");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices9, "pr_setup_popupservices9");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices10, "pr_setup_popupservices10");
+    PROFILE_METHOD_PRINT(pr_setup_popupservices11, "pr_setup_popupservices11");
 }
 
 void KonqPopupMenu::slotOpenShareFileDialog()
@@ -1113,39 +1293,120 @@
     return m_info;
 }
 
+int pr_addplugins1 = 0;
+int pr_addplugins2 = 0;
+int pr_addplugins3 = 0;
+int pr_addplugins4 = 0;
+int pr_addplugins5 = 0;
+int pr_addplugins6 = 0;
+int pr_addplugins7 = 0;
+
 void KonqPopupMenu::addPlugins()
 {
     // search for Konq_PopupMenuPlugins inspired by simons kpropsdlg
     //search for a plugin with the right protocol
+
+    PROFILE_METHOD_BEGIN(pr_addplugins1);
+
     KTrader::OfferList plugin_offers;
     unsigned int pluginCount = 0;
+
+    PROFILE_METHOD_END(pr_addplugins1);
+    PROFILE_METHOD_BEGIN(pr_addplugins2);
+
+    // This is around 32% of the creation time.
+
+#if 0
+    static QMap<QString, KTrader::OfferList> offer_cache;
+
+    QString query = m_sMimeType.isNull() ? QString::fromLatin1( "all/all" ) : \
m_sMimeType; +
+    if ( !offer_cache.contains( query ) )
+	offer_cache.insert( query, KTrader::self()->query( query, "'KonqPopupMenu/Plugin' \
in ServiceTypes") ); +
+    plugin_offers = offer_cache[ query ];
+#else
     plugin_offers = KTrader::self()->query( m_sMimeType.isNull() ? \
QString::fromLatin1( "all/all" ) : m_sMimeType, "'KonqPopupMenu/Plugin' in \
ServiceTypes"); +#endif
+
+    PROFILE_METHOD_END(pr_addplugins2);
+    PROFILE_METHOD_BEGIN(pr_addplugins3);
+
     if ( plugin_offers.isEmpty() )
         return; // no plugins installed do not bother about it
 
+    PROFILE_METHOD_END(pr_addplugins3);
+    PROFILE_METHOD_BEGIN(pr_addplugins4);
+
     KTrader::OfferList::ConstIterator iterator = plugin_offers.begin();
     KTrader::OfferList::ConstIterator end = plugin_offers.end();
 
+
     addGroup( "plugins" );
+
+    PROFILE_METHOD_END(pr_addplugins4);
+
     // travers the offerlist
     for(; iterator != end; ++iterator, ++pluginCount ) {
         //kdDebug() << (*iterator)->library() << endl;
+
+	PROFILE_METHOD_BEGIN(pr_addplugins5);
+
+	// This is about 50% of the creation time.
+
+#if 0
+	static QDict<KonqPopupMenuPlugin> plugin_cache;
+
+        KonqPopupMenuPlugin *plugin = plugin_cache[ (*iterator)->library() ];
+
+	if ( !plugin )
+	{
+	    plugin = KParts::ComponentFactory::
+		createInstanceFromLibrary<KonqPopupMenuPlugin>( QFile::encodeName( \
(*iterator)->library() ), +								this,
+								(*iterator)->name().latin1() );
+	    plugin_cache.insert( (*iterator)->library(), plugin );
+
+	    plugin_cache.setAutoDelete( true );
+	}
+
+#else
         KonqPopupMenuPlugin *plugin =
             KParts::ComponentFactory::
             createInstanceFromLibrary<KonqPopupMenuPlugin>( QFile::encodeName( \
(*iterator)->library() ),  this,
                                                             \
(*iterator)->name().latin1() ); +#endif
+	PROFILE_METHOD_END(pr_addplugins5);
+	kdDebug() << (*iterator)->name() << endl;
+	PROFILE_METHOD_PRINT(pr_addplugins5, "pr_addplugins5");
+    
         if ( !plugin )
             continue;
+
+	PROFILE_METHOD_BEGIN(pr_addplugins6);
+
         QString pluginClientName = QString::fromLatin1( "Plugin%1" ).arg( \
pluginCount );  addMerge( pluginClientName );
         plugin->domDocument().documentElement().setAttribute( "name", \
pluginClientName );  m_pluginList.append( plugin );
         insertChildClient( plugin );
+
+	PROFILE_METHOD_END(pr_addplugins6);
     }
 
     // ## Where is this used?
+    PROFILE_METHOD_BEGIN(pr_addplugins7);
     addMerge( "plugins" );
+    PROFILE_METHOD_END(pr_addplugins7);
+
+    PROFILE_METHOD_PRINT(pr_addplugins1, "pr_addplugins1");
+    PROFILE_METHOD_PRINT(pr_addplugins2, "pr_addplugins2");
+    PROFILE_METHOD_PRINT(pr_addplugins3, "pr_addplugins3");
+    PROFILE_METHOD_PRINT(pr_addplugins4, "pr_addplugins4");
+    PROFILE_METHOD_PRINT(pr_addplugins5, "pr_addplugins5");
+    PROFILE_METHOD_PRINT(pr_addplugins6, "pr_addplugins6");
+    PROFILE_METHOD_PRINT(pr_addplugins7, "pr_addplugins7");
 }
 
 KURL KonqPopupMenu::url() const // ### should be viewURL()



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic