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

List:       kde-commits
Subject:    [kdepim-runtime/KDE/4.9] resources/maildir/libmaildir: Speed up subFolder(), called by folderForColl
From:       David Faure <faure () kde ! org>
Date:       2012-06-30 14:02:49
Message-ID: 20120630140249.E84B8A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit cba5a9845b76fcdb040a1f9d3d0a3e3dc44bff54 by David Faure.
Committed on 30/06/2012 at 15:32.
Pushed by dfaure into branch 'KDE/4.9'.

Speed up subFolder(), called by folderForCollection, i.e. very often.

It used to check that the whole maildir structure was valid everywhere,
every time it was called, which was pretty slow. We only care for one
subfolder in this code path.

Discussed with Kevin Krammer, approved by the unit tests :-)

M  +7    -10   resources/maildir/libmaildir/maildir.cpp

http://commits.kde.org/kdepim-runtime/cba5a9845b76fcdb040a1f9d3d0a3e3dc44bf=
f54

diff --git a/resources/maildir/libmaildir/maildir.cpp b/resources/maildir/l=
ibmaildir/maildir.cpp
index 1ac4141..b6bb579 100644
--- a/resources/maildir/libmaildir/maildir.cpp
+++ b/resources/maildir/libmaildir/maildir.cpp
@@ -350,18 +350,15 @@ bool Maildir::removeSubFolder( const QString& folderN=
ame )
 =

 Maildir Maildir::subFolder( const QString& subFolder ) const
 {
-    if ( isValid() ) {
-        // make the subdir dir
-        QDir dir( d->path );
-        if ( !d->isRoot ) {
-            dir.cdUp();
-            if ( dir.exists( d->subDirPath() ) ) {
-                dir.cd( d->subDirPath() );
-            }
+    // make the subdir dir
+    QDir dir( d->path );
+    if ( !d->isRoot ) {
+        dir.cdUp();
+        if ( dir.exists( d->subDirPath() ) ) {
+            dir.cd( d->subDirPath() );
         }
-        return Maildir( dir.path() + QLatin1Char( '/' ) + subFolder );
     }
-    return Maildir();
+    return Maildir( dir.path() + QLatin1Char( '/' ) + subFolder );
 }
 =

 Maildir Maildir::parent() const
[prev in list] [next in list] [prev in thread] [next in thread] 

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