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

List:       kde-core-devel
Subject:    Small speedup of kded
From:       Waldo Bastian <bastian () kde ! org>
Date:       2000-08-29 4:43:00
[Download RAW message or body]

The following patch makes kded a little bit faster (+/- 25%) when scanning 
the directory tree by checking directories only once.

Cheers,
Waldo
-- 
KDE/Linux, made for people, made by people.



["kded.diff" (text/x-c++)]

? kded.diff
Index: kded.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kded/kded.cpp,v
retrieving revision 1.28
diff -u -r1.28 kded.cpp
--- kded.cpp	2000/07/18 13:06:47	1.28
+++ kded.cpp	2000/08/29 04:44:34
@@ -128,7 +128,6 @@
    proc << locate("exe","kbuildsycoca");
    proc << "--incremental";
    proc.start( KProcess::Block );
-
    build();
 }
 
@@ -166,14 +165,21 @@
 {
   // kdDebug(7020) << QString("reading %1").arg(_path) << endl;
 
+  QString path( _path );
+  if ( path.right(1) != "/" )
+    path += "/";
+
+  if ( m_pDirWatch->contains( path ) ) // Already seen this one?
+     return;
+
   QDir d( _path, QString::null, QDir::Unsorted, QDir::AccessMask | QDir::Dirs );
   // set QDir ...
   if ( !d.exists() )                            // exists&isdir?
+  {
+    kdDebug(7020) << QString("Does not exist! (%1)").arg(_path) << endl;
     return;                             // return false
+  }
 
-  QString path( _path );
-  if ( path.right(1) != "/" )
-    path += "/";
 
   QString file;
 
@@ -181,17 +187,13 @@
   //                           Setting dirs
   //************************************************************************
 
-  if ( !m_pDirWatch->contains( path ) ) // New dir?
+  m_pDirWatch->addDir(path);          // add watch on this dir
+  if (!m_needUpdate)
   {
-    m_pDirWatch->addDir(path);          // add watch on this dir
-    if (!m_needUpdate)
-    {
-       time_t ctime = m_pDirWatch->ctime(path);
-       if (ctime && (ctime > m_sycocaDate))
-          m_needUpdate = true;
-    }
+     time_t ctime = m_pDirWatch->ctime(path);
+     if (ctime && (ctime > m_sycocaDate))
+        m_needUpdate = true;
   }
-
   // Note: If some directory is gone, dirwatch will delete it from the list.
 
   //************************************************************************


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

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