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

List:       kde-commits
Subject:    kdenox/konq-embed/dropin
From:       Eva Brucherseifer <eva () kde ! org>
Date:       2006-05-11 16:30:23
Message-ID: 1147365023.292774.26344.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 539747 by eva:

This patch really speedsup reading config files. The drawback is, that
more memory is needed. 

Thanks to Uli Luckas (ROAD GmbH) for the patch.



 M  +13 -4     kconfig.cpp  


--- trunk/kdenox/konq-embed/dropin/kconfig.cpp #539746:539747
@@ -226,11 +226,20 @@
     if ( !f.open( IO_ReadOnly ) )
         return;
 
-    while ( !f.atEnd() )
+    QTextStream textStream( &f );
+    textStream.setEncoding( QTextStream::UnicodeUTF8 );
+    QString content = textStream.read();
+    QString stripped;
+    int solIndex = 0;
+    int eolIndex;
+
+    while ( solIndex < content.length() )
     {
-        QTextStream textStream( &f );
-        textStream.setEncoding( QTextStream::UnicodeUTF8 );
-        QString stripped = textStream.readLine().stripWhiteSpace();
+        eolIndex = content.find('\n', solIndex);
+        if (eolIndex == -1)
+            eolIndex = content.length();
+        stripped = content.mid(solIndex, eolIndex - solIndex).stripWhiteSpace();
+        solIndex = eolIndex + 1;
         int pos = -1;
         // comment? skip
         if ( stripped[ 0 ] == '#' )
[prev in list] [next in list] [prev in thread] [next in thread] 

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