Merge "Small optimizations for single code point strings"

main
Ken Wakasa 2013-11-27 03:43:45 +00:00 committed by Android (Google) Code Review
commit ccac553182
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) {