From 0de7a6d1a272d52a9544df1c693ae199ab5abc52 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 20 Mar 2014 18:33:38 +0900 Subject: [CB15] Remove a redundant variable. This is a tiny bit slower, but probably unnoticeable. Still, it gains some performance in other places, saves memory, and more importantly makes for simpler code, so it's certainly better. Change-Id: Id1ab4f73f71acd73f5920bc729817abd22cf0d07 --- .../com/android/inputmethod/latin/BinaryDictionary.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java') diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 0aa34e82e..323d0c8a3 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -249,8 +249,18 @@ public final class BinaryDictionary extends Dictionary { final boolean isGesture = composer.isBatchMode(); if (composerSize <= 1 || !isGesture) { if (composerSize > MAX_WORD_LENGTH - 1) return null; - for (int i = 0; i < composerSize; i++) { - mInputCodePoints[i] = composer.getCodeAt(i); + final CharSequence typedWord = composer.getTypedWord(); + final int charCount = typedWord.length(); + int typedWordCharIndex = 0; + int inputCodePointIndex = 0; + while (typedWordCharIndex < charCount) { + final int codePoint = Character.codePointAt(typedWord, typedWordCharIndex); + mInputCodePoints[inputCodePointIndex] = codePoint; + typedWordCharIndex += Character.charCount(codePoint); + inputCodePointIndex += 1; + if (inputCodePointIndex >= MAX_WORD_LENGTH) { + break; + } } } -- cgit v1.2.3-83-g751a