1
0
Fork 0

the Languages screen now loads more than 100x faster, thanks to optimizing Text.capitalize()

This commit is contained in:
sspanak 2024-04-24 14:46:49 +03:00
parent b609178976
commit 67d17e2914
2 changed files with 5 additions and 7 deletions

View file

@ -240,8 +240,8 @@ public class NaturalLanguage extends Language implements Comparable<NaturalLangu
@Override @Override
public int compareTo(NaturalLanguage other) { public int compareTo(NaturalLanguage other) {
String key = getName().equals("Suomi") ? "su" : getLocale().toString(); String key = getLocale().getCountry().equals("FI") ? "su" : getLocale().toString();
String otherKey = other.getName().equals("Suomi") ? "su" : other.getLocale().toString(); String otherKey = other.getLocale().getCountry().equals("FI") ? "su" : other.getLocale().toString();
return key.compareTo(otherKey); return key.compareTo(otherKey);
} }
} }

View file

@ -25,11 +25,9 @@ public class Text extends TextTools {
return text; return text;
} }
if (text.length() == 1) { char[] chars = text.toCharArray();
return text.toUpperCase(language.getLocale()); chars[0] = Character.toUpperCase(chars[0]);
} else { return String.valueOf(chars);
return text.substring(0, 1).toUpperCase(language.getLocale()) + text.substring(1);
}
} }