Deduplicate a common check for legacy codes
All of QLocalePrivate::codeToLanguage()'s legacy codes were two-letter, so duplicated a "third letter is 0" check; pulling it out in front of them all will get any three-letter code more promptly to the final fall-back, while saving the two-letter codes repetition of the check. Change-Id: I8ee81a526adaa7b24c11c1de7a1750d87deb5fb3 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
9856f869f5
commit
1c1f42b4dc
@ -110,31 +110,32 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) Q_DECL_NOTHRO
|
|||||||
return QLocale::Language((c - language_code_list)/3);
|
return QLocale::Language((c - language_code_list)/3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uc3 == 0) {
|
||||||
// legacy codes
|
// legacy codes
|
||||||
if (uc1 == 'n' && uc2 == 'o' && uc3 == 0) { // no -> nb
|
if (uc1 == 'n' && uc2 == 'o') { // no -> nb
|
||||||
Q_STATIC_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
Q_STATIC_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
|
||||||
return QLocale::Norwegian;
|
return QLocale::Norwegian;
|
||||||
}
|
}
|
||||||
if (uc1 == 't' && uc2 == 'l' && uc3 == 0) { // tl -> fil
|
if (uc1 == 't' && uc2 == 'l') { // tl -> fil
|
||||||
Q_STATIC_ASSERT(QLocale::Tagalog == QLocale::Filipino);
|
Q_STATIC_ASSERT(QLocale::Tagalog == QLocale::Filipino);
|
||||||
return QLocale::Tagalog;
|
return QLocale::Tagalog;
|
||||||
}
|
}
|
||||||
if (uc1 == 's' && uc2 == 'h' && uc3 == 0) { // sh -> sr[_Latn]
|
if (uc1 == 's' && uc2 == 'h') { // sh -> sr[_Latn]
|
||||||
Q_STATIC_ASSERT(QLocale::SerboCroatian == QLocale::Serbian);
|
Q_STATIC_ASSERT(QLocale::SerboCroatian == QLocale::Serbian);
|
||||||
return QLocale::SerboCroatian;
|
return QLocale::SerboCroatian;
|
||||||
}
|
}
|
||||||
if (uc1 == 'm' && uc2 == 'o' && uc3 == 0) { // mo -> ro
|
if (uc1 == 'm' && uc2 == 'o') { // mo -> ro
|
||||||
Q_STATIC_ASSERT(QLocale::Moldavian == QLocale::Romanian);
|
Q_STATIC_ASSERT(QLocale::Moldavian == QLocale::Romanian);
|
||||||
return QLocale::Moldavian;
|
return QLocale::Moldavian;
|
||||||
}
|
}
|
||||||
// Android uses the following deprecated codes
|
// Android uses the following deprecated codes
|
||||||
if (uc1 == 'i' && uc2 == 'w' && uc3 == 0) // iw -> he
|
if (uc1 == 'i' && uc2 == 'w') // iw -> he
|
||||||
return QLocale::Hebrew;
|
return QLocale::Hebrew;
|
||||||
if (uc1 == 'i' && uc2 == 'n' && uc3 == 0) // in -> id
|
if (uc1 == 'i' && uc2 == 'n') // in -> id
|
||||||
return QLocale::Indonesian;
|
return QLocale::Indonesian;
|
||||||
if (uc1 == 'j' && uc2 == 'i' && uc3 == 0) // ji -> yi
|
if (uc1 == 'j' && uc2 == 'i') // ji -> yi
|
||||||
return QLocale::Yiddish;
|
return QLocale::Yiddish;
|
||||||
|
}
|
||||||
return QLocale::C;
|
return QLocale::C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user