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

List:       kde-commits
Subject:    kdelibs/kdeui
From:       Maks Orlovich <mo002j () mail ! rochester ! edu>
Date:       2003-04-18 21:05:40
[Download RAW message or body]

CVS commit by orlovich: 


Don't create massive dictionary's as global statics. It:

1. Wastes memory (200K per process here, even if they don't use this!)
2. Toggles a horrific interaction with artsdsp (which is often used w/nspluginviewer) \
 where a malloc for the dict data toggles mmap, which gets intercepted by artsdsp, \
which starts its initialization  process by calling dlsym, which, in turn, calls \
calloc, and ends up spinning forever waiting for heap access.

This will probably effectively fix flash for some folks


  M +18 -7     ksyntaxhighlighter.cpp   1.4


--- kdelibs/kdeui/ksyntaxhighlighter.cpp  #1.3:1.4
@@ -77,5 +77,11 @@ public:
     }
 
-    static QDict<int> sDict;
+    static QDict<int>* sDict()
+    {
+        if (!statDict)
+            statDict = new QDict<int>(50021);
+        return statDict;
+    }
+    
     QDict<int> autoDict;
     QDict<int> autoIgnoreDict;
@@ -86,6 +92,12 @@ public:
     int wordCount, errorCount;
     bool active, automatic, autoReady;
+private:
+    static QDict<int>* statDict;
+    
 };
 
+QDict<int>* KDictSpellingHighlighter::KDictSpellingHighlighterPrivate::statDict = 0;
+
+
 KSyntaxHighlighter::KSyntaxHighlighter( QTextEdit *textEdit,
                                           bool colorQuoting,
@@ -235,5 +247,4 @@ void KSpellingHighlighter::flushCurrentW
 }
 
-QDict<int> KDictSpellingHighlighter::KDictSpellingHighlighterPrivate::sDict( 50021 \
);  QObject *KDictSpellingHighlighter::KDictSpellingHighlighterPrivate::sDictionaryMonitor \
= 0;  
@@ -301,5 +312,5 @@ bool KDictSpellingHighlighter::isMisspel
 
     // "dict" is used as a cache to store the results of KSpell
-    if ( !d->sDict.isEmpty() && d->sDict[word] == NotOkay ) {
+    if ( !d->sDict()->isEmpty() && (*d->sDict())[word] == NotOkay ) {
         if ( d->autoReady && ( d->autoDict[word] != NotOkay )) {
             if ( !d->autoIgnoreDict[word] ) {
@@ -312,5 +323,5 @@ bool KDictSpellingHighlighter::isMisspel
         return d->active;
     }
-    if ( !d->sDict.isEmpty() && d->sDict[word] == Okay ) {
+    if ( !d->sDict()->isEmpty() && (*d->sDict())[word] == Okay ) {
         if ( d->autoReady && !d->autoDict[word] ) {
             d->autoDict.replace( word, Okay );
@@ -322,5 +333,5 @@ bool KDictSpellingHighlighter::isMisspel
 
     // there is no 'spelt correctly' signal so default to Okay
-    d->sDict.replace( word, Okay );
+    d->sDict()->replace( word, Okay );
 
     // yes I tried checkWord, the docs lie and it didn't give useful signals :-(
@@ -344,5 +355,5 @@ void KDictSpellingHighlighter::slotMissp
     Q_UNUSED( suggestions );
     // kdDebug() << suggestions.join( " " ).latin1() << endl;
-    d->sDict.replace( originalWord, NotOkay );
+    d->sDict()->replace( originalWord, NotOkay );
 
     // this is slow but since kspell is async this will have to do for now
@@ -354,5 +365,5 @@ void KDictSpellingHighlighter::dictionar
     QObject *oldMonitor = KDictSpellingHighlighterPrivate::sDictionaryMonitor;
     KDictSpellingHighlighterPrivate::sDictionaryMonitor = new QObject();
-    KDictSpellingHighlighterPrivate::sDict.clear();
+    KDictSpellingHighlighterPrivate::sDict()->clear();
     delete oldMonitor;
 }


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

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