Small optimizations for single code point strings

Change-Id: I299c7622db291ea411e2b48dfdb622b407912ea6
This commit is contained in:
Ken Wakasa 2013-11-27 12:40:13 +09:00
parent fd15afae46
commit c01dba872c
3 changed files with 3 additions and 3 deletions

View file

@ -483,7 +483,7 @@ public final class KeySpecParser {
public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase, public static int toUpperCaseOfCodeForLocale(final int code, final boolean needsToUpperCase,
final Locale locale) { final Locale locale) {
if (!Constants.isLetterCode(code) || !needsToUpperCase) return code; if (!Constants.isLetterCode(code) || !needsToUpperCase) return code;
final String text = new String(new int[] { code } , 0, 1); final String text = StringUtils.newSingleCodePointString(code);
final String casedText = KeySpecParser.toUpperCaseOfStringForLocale( final String casedText = KeySpecParser.toUpperCaseOfStringForLocale(
text, needsToUpperCase, locale); text, needsToUpperCase, locale);
return StringUtils.codePointCount(casedText) == 1 return StringUtils.codePointCount(casedText) == 1

View file

@ -428,7 +428,7 @@ public final class RichInputConnection {
} }
break; break;
default: default:
final String text = new String(new int[] { keyEvent.getUnicodeChar() }, 0, 1); final String text = StringUtils.newSingleCodePointString(keyEvent.getUnicodeChar());
mCommittedTextBeforeComposingText.append(text); mCommittedTextBeforeComposingText.append(text);
mExpectedSelStart += text.length(); mExpectedSelStart += text.length();
mExpectedSelEnd = mExpectedSelStart; mExpectedSelEnd = mExpectedSelStart;

View file

@ -35,7 +35,7 @@ public final class LatinImeLoggerUtils {
public static void onSeparator(final int code, final int x, final int y) { public static void onSeparator(final int code, final int x, final int y) {
// Helper method to log a single code point separator // Helper method to log a single code point separator
// TODO: cache this mapping of a code point to a string in a sparse array in StringUtils // TODO: cache this mapping of a code point to a string in a sparse array in StringUtils
onSeparator(new String(new int[]{code}, 0, 1), x, y); onSeparator(StringUtils.newSingleCodePointString(code), x, y);
} }
public static void onSeparator(final String separator, final int x, final int y) { public static void onSeparator(final String separator, final int x, final int y) {