opt: langcoder optimization

This commit is contained in:
Xiao YiFang 2022-06-23 20:03:29 +08:00
parent af4946d7a7
commit 4e4c9375be

View file

@ -207,17 +207,14 @@ static GDLangCode LangCodes[] = {
{ "zh", "chi", 0, "Chinese" }, { "zh", "chi", 0, "Chinese" },
{ "zu", "zul", -1, "Zulu" }, { "zu", "zul", -1, "Zulu" },
{ "jb", "jbo", 0, "Lojban" }, { "jb", "jbo", 0, "Lojban" },
{ "", "", 0, "" }
}; };
LangCoder::LangCoder() LangCoder::LangCoder()
{ {
for (int i = 0; true; i++) { int i = 0;
const GDLangCode &lc = LangCodes[i]; for (const auto lc : LangCodes)
if (lc.lang[0] == 0) {
break; codeMap[ code2toInt( lc.code ) ] = i++;
codeMap[code2toInt(lc.code)] = i;
} }
} }