Subject: Spell checker working overtime & fix
From: Nikolaj Brandt Jensen (mailbag@postman.dk)
Date: Fri Jun 29 2001 - 13:00:23 CDT
Hello.
I have found that the spell checker is working at full speed, even if
the dictionary hash isn't present.
It checks for the presence of the hash file 150 times a second! And
the linit() function takes up 14% of the execution time when profiling
AW.
Shouldn't the spell checker keep a flag saying hash gone (probably for
each language), and only retry loading it e.g. the next time the user
manually issues a spell check?
Hmm... Looking at SpellManager::requestDictionary(), it actually does
that. Unfortunately it doesn't work... 
OK, UT_StringPtrMap can't be used to store NULL value hash entries
because of UT_StringPtrMap::find_slot()/hash_slot::empty(), so the
code in requestDictionary() won't work.
If someone can commit this, AW will behave much better.
Add this to the SpellManager class in
src/other/spell/xp/spell_manager.h:
UT_String m_missingHashs;
And change the function in src/other/spell/xp/spell_manager.cpp to:
SpellChecker *
SpellManager::requestDictionary (const char * szLang)
{  
        SpellCheckerClass * checker = 0;
        
        // Don't try to load hashes we know are missing
        if (strstr(m_missingHashs.c_str(), szLang))
                return 0;
        // first look up the entry in the hashtable
        if (m_map.contains (szLang, 0))
        {
                return (SpellCheckerClass *)m_map.pick (szLang);
        }
        // not found, so insert it
        checker = new SpellCheckerClass ();
        
        if (checker->requestDictionary (szLang))
    {      
                m_map.insert (szLang, (void *)checker);
                m_lastDict = checker;
                return checker;
    }
        else
    {
                m_missingHashs += szLang;
                delete checker;
                return 0;
    }
}
I have a few ideas for making this even better, but I sense that 0.9
is approaching fast  :-)
        - Nikolaj
This archive was generated by hypermail 2b25 : Fri Jun 29 2001 - 13:00:38 CDT