switch statement cleanup (#148382)
This PR is step 12 in the journey to solve issue #136139 and make the entire Flutter repo more readable. Most of it involves implementing switch expressions, and there's also a few other random things that I wanted to clean up a bit.
This commit is contained in:
@@ -62,29 +62,12 @@ class LocaleInfo implements Comparable<LocaleInfo> {
|
||||
/// across various countries. For example, we know Taiwan uses traditional (Hant)
|
||||
/// script, so it is safe to apply (Hant) to Taiwanese languages.
|
||||
if (deriveScriptCode && scriptCode == null) {
|
||||
switch (languageCode) {
|
||||
case 'zh': {
|
||||
if (countryCode == null) {
|
||||
scriptCode = 'Hans';
|
||||
}
|
||||
switch (countryCode) {
|
||||
case 'CN':
|
||||
case 'SG':
|
||||
scriptCode = 'Hans';
|
||||
case 'TW':
|
||||
case 'HK':
|
||||
case 'MO':
|
||||
scriptCode = 'Hant';
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'sr': {
|
||||
if (countryCode == null) {
|
||||
scriptCode = 'Cyrl';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
scriptCode = switch ((languageCode, countryCode)) {
|
||||
('zh', 'CN' || 'SG' || null) => 'Hans',
|
||||
('zh', 'TW' || 'HK' || 'MO') => 'Hant',
|
||||
('sr', null) => 'Cyrl',
|
||||
_ => null,
|
||||
};
|
||||
// Increment length if we were able to assume a scriptCode.
|
||||
if (scriptCode != null) {
|
||||
length += 1;
|
||||
|
||||
Reference in New Issue
Block a user