mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-03 14:13:58 +00:00
Do not store Languages objects in completion words lists
In the current code each paragraph contains a map<Language, WordList*>, which means that it contains a full copy of the language object. Since these objects contain translation tables nowadays, this is a very bad idea. This patch simply replaces the Language key by a string. When loading the Userguide on linux/x86_64, the total memory consumption decreases from 36.27MB to 31.50MB.
This commit is contained in:
parent
8b60088eaa
commit
a556652f6e
@ -33,6 +33,7 @@
|
|||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
#include "HunspellChecker.h"
|
#include "HunspellChecker.h"
|
||||||
#include "KeyMap.h"
|
#include "KeyMap.h"
|
||||||
|
#include "Language.h"
|
||||||
#include "LaTeXFonts.h"
|
#include "LaTeXFonts.h"
|
||||||
#include "LayoutFile.h"
|
#include "LayoutFile.h"
|
||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
|
@ -499,7 +499,7 @@ public:
|
|||||||
TextContainer text_;
|
TextContainer text_;
|
||||||
|
|
||||||
typedef set<docstring> Words;
|
typedef set<docstring> Words;
|
||||||
typedef map<Language, Words> LangWordsMap;
|
typedef map<string, Words> LangWordsMap;
|
||||||
///
|
///
|
||||||
LangWordsMap words_;
|
LangWordsMap words_;
|
||||||
///
|
///
|
||||||
@ -3867,7 +3867,7 @@ void Paragraph::collectWords()
|
|||||||
if (cit == d->fontlist_.end())
|
if (cit == d->fontlist_.end())
|
||||||
return;
|
return;
|
||||||
Language const * lang = cit->font().language();
|
Language const * lang = cit->font().language();
|
||||||
d->words_[*lang].insert(word);
|
d->words_[lang->lang()].insert(word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2120,7 +2120,7 @@ bool Text::completionSupported(Cursor const & cur) const
|
|||||||
|
|
||||||
CompletionList const * Text::createCompletionList(Cursor const & cur) const
|
CompletionList const * Text::createCompletionList(Cursor const & cur) const
|
||||||
{
|
{
|
||||||
WordList const * list = theWordList(*cur.getFont().language());
|
WordList const * list = theWordList(cur.getFont().language()->lang());
|
||||||
return new TextCompletionList(cur, list);
|
return new TextCompletionList(cur, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,11 @@
|
|||||||
|
|
||||||
#include "WordList.h"
|
#include "WordList.h"
|
||||||
|
|
||||||
#include "Language.h"
|
|
||||||
|
|
||||||
#include "support/convert.h"
|
#include "support/convert.h"
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
#include "support/weighted_btree.h"
|
|
||||||
|
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
|
#include "support/weighted_btree.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -28,12 +25,13 @@ using namespace std;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
///
|
///
|
||||||
map<Language, WordList *> theGlobalWordList;
|
typedef map<string, WordList *> GlobalWordList;
|
||||||
|
GlobalWordList theGlobalWordList;
|
||||||
|
|
||||||
|
|
||||||
WordList * theWordList(Language const & lang)
|
WordList * theWordList(string const & lang)
|
||||||
{
|
{
|
||||||
map<Language, WordList *>::iterator it = theGlobalWordList.find(lang);
|
GlobalWordList::iterator it = theGlobalWordList.find(lang);
|
||||||
if (it != theGlobalWordList.end())
|
if (it != theGlobalWordList.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
else
|
else
|
||||||
@ -44,7 +42,7 @@ WordList * theWordList(Language const & lang)
|
|||||||
|
|
||||||
void WordList::cleanupWordLists()
|
void WordList::cleanupWordLists()
|
||||||
{
|
{
|
||||||
map<Language, WordList *>::const_iterator it = theGlobalWordList.begin();
|
GlobalWordList::const_iterator it = theGlobalWordList.begin();
|
||||||
for (; it != theGlobalWordList.end(); ++it)
|
for (; it != theGlobalWordList.end(); ++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
theGlobalWordList.clear();
|
theGlobalWordList.clear();
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include "Language.h"
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class WordList {
|
class WordList {
|
||||||
@ -41,7 +39,7 @@ private:
|
|||||||
Impl * d;
|
Impl * d;
|
||||||
};
|
};
|
||||||
|
|
||||||
WordList * theWordList(Language const & lang);
|
WordList * theWordList(std::string const & lang);
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ What's new
|
|||||||
|
|
||||||
- Fix a problem when PATH changes and python command is relative (bug 8950).
|
- Fix a problem when PATH changes and python command is relative (bug 8950).
|
||||||
|
|
||||||
|
- Reduce memory use with large documents.
|
||||||
|
|
||||||
|
|
||||||
* DOCUMENTATION AND LOCALIZATION
|
* DOCUMENTATION AND LOCALIZATION
|
||||||
|
Loading…
Reference in New Issue
Block a user