mnemonics: fix outrageous compile time with CLANG in release

from several minutes to 10-15 seconds
This commit is contained in:
moneromooo-monero 2018-08-29 09:42:23 +00:00
parent 91c7d68b2d
commit f0bc684ccd
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
14 changed files with 89 additions and 41 deletions

View file

@ -72,7 +72,10 @@ namespace Language
class Chinese_Simplified: public Base class Chinese_Simplified: public Base
{ {
public: public:
Chinese_Simplified(): Base("简体中文 (中国)", "Chinese (simplified)", std::vector<std::string>({ Chinese_Simplified(): Base("简体中文 (中国)", "Chinese (simplified)", {}, 1)
{
static constexpr const char * const words[NWORDS] =
{
"", "",
"", "",
"", "",
@ -1699,8 +1702,8 @@ namespace Language
"", "",
"", "",
"" ""
}), 1) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -49,7 +49,10 @@ namespace Language
class Dutch: public Base class Dutch: public Base
{ {
public: public:
Dutch(): Base("Nederlands", "Dutch", std::vector<std::string>({ Dutch(): Base("Nederlands", "Dutch", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"aalglad", "aalglad",
"aalscholver", "aalscholver",
"aambeeld", "aambeeld",
@ -1676,8 +1679,8 @@ namespace Language
"zwiep", "zwiep",
"zwijmel", "zwijmel",
"zworen" "zworen"
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -49,7 +49,10 @@ namespace Language
class English: public Base class English: public Base
{ {
public: public:
English(): Base("English", "English", std::vector<std::string>({ English(): Base("English", "English", {}, 3)
{
static constexpr const char * const words[NWORDS] =
{
"abbey", "abbey",
"abducts", "abducts",
"ability", "ability",
@ -1676,8 +1679,8 @@ namespace Language
"zombie", "zombie",
"zones", "zones",
"zoom" "zoom"
}), 3) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -51,7 +51,10 @@ namespace Language
class EnglishOld: public Base class EnglishOld: public Base
{ {
public: public:
EnglishOld(): Base("EnglishOld", "English (old)", std::vector<std::string>({ EnglishOld(): Base("EnglishOld", "English (old)", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"like", "like",
"just", "just",
"love", "love",
@ -1678,8 +1681,8 @@ namespace Language
"unseen", "unseen",
"weapon", "weapon",
"weary" "weary"
}), 4) };
{ set_words(words);
populate_maps(ALLOW_DUPLICATE_PREFIXES | ALLOW_SHORT_WORDS); populate_maps(ALLOW_DUPLICATE_PREFIXES | ALLOW_SHORT_WORDS);
} }
}; };

View file

@ -58,7 +58,10 @@ namespace Language
class Esperanto: public Base class Esperanto: public Base
{ {
public: public:
Esperanto(): Base("Esperanto", "Esperanto", std::vector<std::string>({ Esperanto(): Base("Esperanto", "Esperanto", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abako", "abako",
"abdiki", "abdiki",
"abelo", "abelo",
@ -1685,8 +1688,8 @@ namespace Language
"zorgi", "zorgi",
"zukino", "zukino",
"zumilo", "zumilo",
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -49,7 +49,10 @@ namespace Language
class French: public Base class French: public Base
{ {
public: public:
French(): Base("Français", "French", std::vector<std::string>({ French(): Base("Français", "French", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abandon", "abandon",
"abattre", "abattre",
"aboi", "aboi",
@ -1676,8 +1679,8 @@ namespace Language
"zinc", "zinc",
"zone", "zone",
"zoom" "zoom"
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -51,7 +51,10 @@ namespace Language
class German: public Base class German: public Base
{ {
public: public:
German(): Base("Deutsch", "German", std::vector<std::string>({ German(): Base("Deutsch", "German", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"Abakus", "Abakus",
"Abart", "Abart",
"abbilden", "abbilden",
@ -1678,8 +1681,8 @@ namespace Language
"Zündung", "Zündung",
"Zweck", "Zweck",
"Zyklop" "Zyklop"
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -51,7 +51,10 @@ namespace Language
class Italian: public Base class Italian: public Base
{ {
public: public:
Italian(): Base("Italiano", "Italian", std::vector<std::string>({ Italian(): Base("Italiano", "Italian", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abbinare", "abbinare",
"abbonato", "abbonato",
"abisso", "abisso",
@ -1678,8 +1681,8 @@ namespace Language
"zolfo", "zolfo",
"zombie", "zombie",
"zucchero" "zucchero"
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -71,7 +71,10 @@ namespace Language
class Japanese: public Base class Japanese: public Base
{ {
public: public:
Japanese(): Base("日本語", "Japanese", std::vector<std::string>({ Japanese(): Base("日本語", "Japanese", {}, 3)
{
static constexpr const char * const words[NWORDS] =
{
"あいこくしん", "あいこくしん",
"あいさつ", "あいさつ",
"あいだ", "あいだ",
@ -1698,8 +1701,8 @@ namespace Language
"ひさん", "ひさん",
"びじゅつかん", "びじゅつかん",
"ひしょ" "ひしょ"
}), 3) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -83,7 +83,10 @@ namespace Language
ALLOW_SHORT_WORDS = 1<<0, ALLOW_SHORT_WORDS = 1<<0,
ALLOW_DUPLICATE_PREFIXES = 1<<1, ALLOW_DUPLICATE_PREFIXES = 1<<1,
}; };
const std::vector<std::string> word_list; /*!< A pointer to the array of words */ enum {
NWORDS = 1626
};
std::vector<std::string> word_list; /*!< A pointer to the array of words */
std::unordered_map<epee::wipeable_string, uint32_t> word_map; /*!< hash table to find word's index */ std::unordered_map<epee::wipeable_string, uint32_t> word_map; /*!< hash table to find word's index */
std::unordered_map<epee::wipeable_string, uint32_t> trimmed_word_map; /*!< hash table to find word's trimmed index */ std::unordered_map<epee::wipeable_string, uint32_t> trimmed_word_map; /*!< hash table to find word's trimmed index */
std::string language_name; /*!< Name of language */ std::string language_name; /*!< Name of language */
@ -96,7 +99,7 @@ namespace Language
{ {
int ii; int ii;
std::vector<std::string>::const_iterator it; std::vector<std::string>::const_iterator it;
if (word_list.size () != 1626) if (word_list.size () != NWORDS)
throw std::runtime_error("Wrong word list length for " + language_name); throw std::runtime_error("Wrong word list length for " + language_name);
for (it = word_list.begin(), ii = 0; it != word_list.end(); it++, ii++) for (it = word_list.begin(), ii = 0; it != word_list.end(); it++, ii++)
{ {
@ -138,6 +141,12 @@ namespace Language
virtual ~Base() virtual ~Base()
{ {
} }
void set_words(const char * const words[])
{
word_list.resize(NWORDS);
for (size_t i = 0; i < NWORDS; ++i)
word_list[i] = words[i];
}
/*! /*!
* \brief Returns a pointer to the word list. * \brief Returns a pointer to the word list.
* \return A pointer to the word list. * \return A pointer to the word list.

View file

@ -56,7 +56,10 @@ namespace Language
class Lojban: public Base class Lojban: public Base
{ {
public: public:
Lojban(): Base("Lojban", "Lojban", std::vector<std::string>({ Lojban(): Base("Lojban", "Lojban", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"backi", "backi",
"bacru", "bacru",
"badna", "badna",
@ -1683,8 +1686,8 @@ namespace Language
"noltruti'u", "noltruti'u",
"samtci", "samtci",
"snaxa'a", "snaxa'a",
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -72,7 +72,10 @@ namespace Language
class Portuguese: public Base class Portuguese: public Base
{ {
public: public:
Portuguese(): Base("Português", "Portuguese", std::vector<std::string>({ Portuguese(): Base("Português", "Portuguese", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abaular", "abaular",
"abdominal", "abdominal",
"abeto", "abeto",
@ -1699,8 +1702,8 @@ namespace Language
"zeloso", "zeloso",
"zenite", "zenite",
"zumbi" "zumbi"
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -51,7 +51,10 @@ namespace Language
class Russian: public Base class Russian: public Base
{ {
public: public:
Russian(): Base("русский язык", "Russian", std::vector<std::string>({ Russian(): Base("русский язык", "Russian", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"абажур", "абажур",
"абзац", "абзац",
"абонент", "абонент",
@ -1678,8 +1681,8 @@ namespace Language
"яхта", "яхта",
"ячейка", "ячейка",
"ящик" "ящик"
}), 4) };
{ set_words(words);
populate_maps(); populate_maps();
} }
}; };

View file

@ -72,7 +72,10 @@ namespace Language
class Spanish: public Base class Spanish: public Base
{ {
public: public:
Spanish(): Base("Español", "Spanish", std::vector<std::string>({ Spanish(): Base("Español", "Spanish", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"ábaco", "ábaco",
"abdomen", "abdomen",
"abeja", "abeja",
@ -1699,8 +1702,8 @@ namespace Language
"risa", "risa",
"ritmo", "ritmo",
"rito" "rito"
}), 4) };
{ set_words(words);
populate_maps(ALLOW_SHORT_WORDS); populate_maps(ALLOW_SHORT_WORDS);
} }
}; };