Delay creation of the thesaurus until it's needed

Although in absolute terms it does not take very long, loading the 18 MB
en_US thesaurus was about three quarters of Aegisub's total startup
time when opening with no command line arguments.

Originally committed to SVN as r6702.
This commit is contained in:
Thomas Goyne 2012-04-16 23:54:47 +00:00
parent 20a31f8e32
commit e5540de2da

View file

@ -82,7 +82,6 @@ enum {
SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, agi::Context *context)
: ScintillaTextCtrl(parent, -1, "", wxDefaultPosition, wsize, style)
, spellchecker(SpellCheckerFactory::GetSpellChecker())
, thesaurus(new Thesaurus)
, context(context)
{
// Set properties
@ -738,7 +737,6 @@ void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) {
if (!currentWord.empty()) {
if (spellchecker)
AddSpellCheckerEntries(menu);
if (thesaurus)
AddThesaurusEntries(menu);
}
@ -792,6 +790,9 @@ void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) {
}
void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) {
if (!thesaurus)
thesaurus.reset(new Thesaurus);
std::vector<Thesaurus::Entry> result;
thesaurus->Lookup(currentWord, &result);
@ -915,6 +916,8 @@ void SubsTextEditCtrl::OnSetDicLanguage(wxCommandEvent &event) {
}
void SubsTextEditCtrl::OnSetThesLanguage(wxCommandEvent &event) {
if (!thesaurus) return;
wxArrayString langs = thesaurus->GetLanguageList();
int index = event.GetId() - EDIT_MENU_THES_LANGS - 1;