- GlobalWordList * globalWordList = theGlobalWordList.localData();
- GlobalWordList::iterator it = globalWordList->find(lang);
- if (it != globalWordList->end())
- return it->second;
- else {
- WordList * wl = new WordList;
- (*globalWordList)[lang] = wl;
- return wl;
- }
-}
-
-
-void WordList::cleanupWordLists()
-{
- if (!theGlobalWordList.hasLocalData())
- return;
- GlobalWordList * globalWordList = theGlobalWordList.localData();
- GlobalWordList::const_iterator it = globalWordList->begin();
- for (; it != globalWordList->end(); ++it)
- delete it->second;
- globalWordList->clear();
+ GlobalWordList & globalWordList = *theGlobalWordList.localData();
+ GlobalWordList::iterator it = globalWordList.find(lang);
+ if (it != globalWordList.end())
+ return *it->second;
+ else
+ return *(globalWordList[lang] = make_unique<WordList>());