Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mnemonics: fix outrageous compile time with CLANG in release #4311

Merged
merged 1 commit into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/mnemonics/chinese_simplified.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ namespace Language
class Chinese_Simplified: public Base
{
public:
Chinese_Simplified(): Base("简体中文 (中国)", "Chinese (simplified)", std::vector<std::string>({
Chinese_Simplified(): Base("简体中文 (中国)", "Chinese (simplified)", {}, 1)
{
static constexpr const char * const words[NWORDS] =
{
"的",
"一",
"是",
Expand Down Expand Up @@ -1699,8 +1702,8 @@ namespace Language
"秒",
"浙",
"貌"
}), 1)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/dutch.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ namespace Language
class Dutch: public Base
{
public:
Dutch(): Base("Nederlands", "Dutch", std::vector<std::string>({
Dutch(): Base("Nederlands", "Dutch", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"aalglad",
"aalscholver",
"aambeeld",
Expand Down Expand Up @@ -1676,8 +1679,8 @@ namespace Language
"zwiep",
"zwijmel",
"zworen"
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/english.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ namespace Language
class English: public Base
{
public:
English(): Base("English", "English", std::vector<std::string>({
English(): Base("English", "English", {}, 3)
{
static constexpr const char * const words[NWORDS] =
{
"abbey",
"abducts",
"ability",
Expand Down Expand Up @@ -1676,8 +1679,8 @@ namespace Language
"zombie",
"zones",
"zoom"
}), 3)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/english_old.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ namespace Language
class EnglishOld: public Base
{
public:
EnglishOld(): Base("EnglishOld", "English (old)", std::vector<std::string>({
EnglishOld(): Base("EnglishOld", "English (old)", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"like",
"just",
"love",
Expand Down Expand Up @@ -1678,8 +1681,8 @@ namespace Language
"unseen",
"weapon",
"weary"
}), 4)
{
};
set_words(words);
populate_maps(ALLOW_DUPLICATE_PREFIXES | ALLOW_SHORT_WORDS);
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/esperanto.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ namespace Language
class Esperanto: public Base
{
public:
Esperanto(): Base("Esperanto", "Esperanto", std::vector<std::string>({
Esperanto(): Base("Esperanto", "Esperanto", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abako",
"abdiki",
"abelo",
Expand Down Expand Up @@ -1685,8 +1688,8 @@ namespace Language
"zorgi",
"zukino",
"zumilo",
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/french.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ namespace Language
class French: public Base
{
public:
French(): Base("Français", "French", std::vector<std::string>({
French(): Base("Français", "French", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abandon",
"abattre",
"aboi",
Expand Down Expand Up @@ -1676,8 +1679,8 @@ namespace Language
"zinc",
"zone",
"zoom"
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/german.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ namespace Language
class German: public Base
{
public:
German(): Base("Deutsch", "German", std::vector<std::string>({
German(): Base("Deutsch", "German", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"Abakus",
"Abart",
"abbilden",
Expand Down Expand Up @@ -1678,8 +1681,8 @@ namespace Language
"Zündung",
"Zweck",
"Zyklop"
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/italian.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ namespace Language
class Italian: public Base
{
public:
Italian(): Base("Italiano", "Italian", std::vector<std::string>({
Italian(): Base("Italiano", "Italian", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abbinare",
"abbonato",
"abisso",
Expand Down Expand Up @@ -1678,8 +1681,8 @@ namespace Language
"zolfo",
"zombie",
"zucchero"
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/japanese.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ namespace Language
class Japanese: public Base
{
public:
Japanese(): Base("日本語", "Japanese", std::vector<std::string>({
Japanese(): Base("日本語", "Japanese", {}, 3)
{
static constexpr const char * const words[NWORDS] =
{
"あいこくしん",
"あいさつ",
"あいだ",
Expand Down Expand Up @@ -1698,8 +1701,8 @@ namespace Language
"ひさん",
"びじゅつかん",
"ひしょ"
}), 3)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
13 changes: 11 additions & 2 deletions src/mnemonics/language_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ namespace Language
ALLOW_SHORT_WORDS = 1<<0,
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> trimmed_word_map; /*!< hash table to find word's trimmed index */
std::string language_name; /*!< Name of language */
Expand All @@ -96,7 +99,7 @@ namespace Language
{
int ii;
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);
for (it = word_list.begin(), ii = 0; it != word_list.end(); it++, ii++)
{
Expand Down Expand Up @@ -138,6 +141,12 @@ namespace Language
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.
* \return A pointer to the word list.
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/lojban.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ namespace Language
class Lojban: public Base
{
public:
Lojban(): Base("Lojban", "Lojban", std::vector<std::string>({
Lojban(): Base("Lojban", "Lojban", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"backi",
"bacru",
"badna",
Expand Down Expand Up @@ -1683,8 +1686,8 @@ namespace Language
"noltruti'u",
"samtci",
"snaxa'a",
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/portuguese.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ namespace Language
class Portuguese: public Base
{
public:
Portuguese(): Base("Português", "Portuguese", std::vector<std::string>({
Portuguese(): Base("Português", "Portuguese", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"abaular",
"abdominal",
"abeto",
Expand Down Expand Up @@ -1699,8 +1702,8 @@ namespace Language
"zeloso",
"zenite",
"zumbi"
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/russian.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ namespace Language
class Russian: public Base
{
public:
Russian(): Base("русский язык", "Russian", std::vector<std::string>({
Russian(): Base("русский язык", "Russian", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"абажур",
"абзац",
"абонент",
Expand Down Expand Up @@ -1678,8 +1681,8 @@ namespace Language
"яхта",
"ячейка",
"ящик"
}), 4)
{
};
set_words(words);
populate_maps();
}
};
Expand Down
9 changes: 6 additions & 3 deletions src/mnemonics/spanish.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ namespace Language
class Spanish: public Base
{
public:
Spanish(): Base("Español", "Spanish", std::vector<std::string>({
Spanish(): Base("Español", "Spanish", {}, 4)
{
static constexpr const char * const words[NWORDS] =
{
"ábaco",
"abdomen",
"abeja",
Expand Down Expand Up @@ -1699,8 +1702,8 @@ namespace Language
"risa",
"ritmo",
"rito"
}), 4)
{
};
set_words(words);
populate_maps(ALLOW_SHORT_WORDS);
}
};
Expand Down