From e5540de2dafcf13bfc75c3feef4870eaaf1de7b9 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 16 Apr 2012 23:54:47 +0000 Subject: [PATCH] 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. --- aegisub/src/subs_edit_ctrl.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aegisub/src/subs_edit_ctrl.cpp b/aegisub/src/subs_edit_ctrl.cpp index ebcc2a403..492f38976 100644 --- a/aegisub/src/subs_edit_ctrl.cpp +++ b/aegisub/src/subs_edit_ctrl.cpp @@ -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,8 +737,7 @@ void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) { if (!currentWord.empty()) { if (spellchecker) AddSpellCheckerEntries(menu); - if (thesaurus) - AddThesaurusEntries(menu); + AddThesaurusEntries(menu); } // Standard actions @@ -792,6 +790,9 @@ void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) { } void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) { + if (!thesaurus) + thesaurus.reset(new Thesaurus); + std::vector 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;