From 860a9f85ff7f2753b7e1bed2e00f86de8eca68e1 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 10 Jul 2012 20:43:19 +0900 Subject: [PATCH] Pull up some common code again (A99) Change-Id: I9e9f5664bb12bb25d74c8a076a6ee1024c708145 --- .../inputmethod/latin/BinaryDictionary.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index f4a4960d7..7da203544 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -114,6 +114,15 @@ public class BinaryDictionary extends Dictionary { // TODO: toLowerCase in the native code final int[] prevWordCodePointArray = (null == prevWord) ? null : StringUtils.toCodePointArray(prevWord.toString()); + final int composerSize = composer.size(); + + if (composerSize <= 1 || !composer.isBatchMode()) { + if (composerSize > MAX_WORD_LENGTH - 1) return null; + for (int i = 0; i < composerSize; i++) { + mInputCodes[i] = composer.getCodeAt(i); + } + } + final int count; if (composer.size() <= 1) { count = TextUtils.isEmpty(prevWord) ? -1 : getBigramsInternal(composer, @@ -142,9 +151,6 @@ public class BinaryDictionary extends Dictionary { private int getBigramsInternal(final WordComposer codes, final int[] previousWord) { int codesSize = codes.size(); - if (codesSize > 0) { - mInputCodes[0] = codes.getCodeAt(0); - } int count = getBigramsNative(mNativeDict, previousWord, previousWord.length, mInputCodes, codesSize, mOutputChars, mOutputScores, MAX_WORD_LENGTH, MAX_BIGRAMS); @@ -165,11 +171,6 @@ public class BinaryDictionary extends Dictionary { codesSize = ips.getPointerSize(); } else { codesSize = codes.size(); - // Won't deal with really long words. - if (codesSize > MAX_WORD_LENGTH - 1) return -1; - for (int i = 0; i < codesSize; i++) { - mInputCodes[i] = codes.getCodeAt(i); - } } return getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(),