File kbuildsycoca_speedup.patch of Package kdelibs3

Index: kbuildservicegroupfactory.cpp
===================================================================
RCS file: /home/kde/kdelibs/kded/kbuildservicegroupfactory.cpp,v
retrieving revision 1.13
diff -u -r1.13 kbuildservicegroupfactory.cpp
--- kded/kbuildservicegroupfactory.cpp	10 Jul 2002 00:55:35 -0000	1.13
+++ kded/kbuildservicegroupfactory.cpp	8 Mar 2003 17:43:11 -0000
@@ -135,6 +135,7 @@
 {
    KSycocaFactory::addEntry(newEntry, resource);
    KServiceGroup * serviceGroup = (KServiceGroup *) newEntry;
+   serviceGroup->m_serviceList.clear();
 
    if ( !serviceGroup->baseGroupName().isEmpty() )
    {
Index: kbuildsycoca.cpp
===================================================================
RCS file: /home/kde/kdelibs/kded/kbuildsycoca.cpp,v
retrieving revision 1.66.2.1
diff -u -r1.66.2.1 kbuildsycoca.cpp
--- kded/kbuildsycoca.cpp	3 Mar 2003 22:18:37 -0000	1.66.2.1
+++ kded/kbuildsycoca.cpp	8 Mar 2003 17:43:12 -0000
@@ -55,6 +55,7 @@
 
 static Q_UINT32 newTimestamp = 0;
 
+static KBuildServiceGroupFactory *g_bsgf = 0;
 static KBuildServiceFactory *g_bsf = 0;
 
 static QStringList *g_changeList = 0;
@@ -231,46 +232,51 @@
                 it3 != relFiles.end();
                 ++it3 )
            {
+               const QString &file = *it3;
                // Check if file matches filter
-               if (res.filter.search(*it3) == -1) continue;
+               if (res.filter.search(file) == -1) continue;
 
-               Q_UINT32 timeStamp = ctimeInfo->ctime(*it3);
+               Q_UINT32 timeStamp = ctimeInfo->ctime(file);
                if (!timeStamp)
                {
-                   timeStamp = KGlobal::dirs()->calcResourceHash( resource, *it3, true);
+                   timeStamp = KGlobal::dirs()->calcResourceHash( resource, file, true);
                }
                KSycocaEntry* entry = 0;
                if (allEntries)
                {
                    assert(ctimeDict);
-                   Q_UINT32 *timeP = (*ctimeDict)[*it3];
+                   Q_UINT32 *timeP = (*ctimeDict)[file];
                    Q_UINT32 oldTimestamp = timeP ? *timeP : 0;
 
                    if (timeStamp && (timeStamp == oldTimestamp))
                    {
                       // Re-use old entry
-                      entry = entryDict->find(*it3);
+                      if (factory == g_bsgf) // Strip .directory from service-group entries
+                         entry = entryDict->find(file.left(file.length()-10));
+                      else
+                        entry = entryDict->find(file);
+
                       // remove from ctimeDict; if ctimeDict is not empty
                       // after all files have been processed, it means
                       // some files were removed since last time
-                      ctimeDict->remove( *it3 );
+                      ctimeDict->remove( file );
                    }
                    else if (oldTimestamp)
                    {
                       changed = true;
-                      kdDebug(7021) << "modified: " << (*it3) << endl;
+                      kdDebug(7021) << "modified: " << (file) << endl;
                    }
                    else 
                    {
                       changed = true;
-                      kdDebug(7021) << "new: " << (*it3) << endl;
+                      kdDebug(7021) << "new: " << (file) << endl;
                    }
                }
-               ctimeInfo->addCTime(*it3, timeStamp );
+               ctimeInfo->addCTime(file, timeStamp );
                if (!entry)
                {
                    // Create a new entry
-                   entry = factory->createEntry( *it3, resource );
+                   entry = factory->createEntry( file, resource );
                }
                if ( entry && entry->isValid() )
                   factory->addEntry( entry, resource );
@@ -310,8 +316,8 @@
   // It is very important to build the servicetype one first
   // Both are registered in KSycoca, no need to keep the pointers
   KSycocaFactory *stf = new KBuildServiceTypeFactory;
-  KBuildServiceGroupFactory *bsgf = new KBuildServiceGroupFactory();
-  g_bsf = new KBuildServiceFactory(stf, bsgf);
+  g_bsgf = new KBuildServiceGroupFactory();
+  g_bsf = new KBuildServiceFactory(stf, g_bsgf);
   (void) new KBuildImageIOFactory();
   (void) new KBuildProtocolInfoFactory();
 
openSUSE Build Service is sponsored by