aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-07-10 22:48:33 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-10 22:48:33 -0700
commita5acd68caacb223b34f3b86f141c91c21d93c604 (patch)
tree4efc858bf272d30a1e0f6433bb7b854f29ad4c2e /java/src
parent0d54692ce4a2af1a2acb1c4fe4f3492613103d8f (diff)
parentb4b93dbf3e0912ba26c5c34abba7a5b94c74138c (diff)
downloadlatinime-a5acd68caacb223b34f3b86f141c91c21d93c604.tar.gz
latinime-a5acd68caacb223b34f3b86f141c91c21d93c604.tar.xz
latinime-a5acd68caacb223b34f3b86f141c91c21d93c604.zip
Merge "Pull up common code in the caller (A94)"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 291d84975..252cdf1f9 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -107,6 +107,10 @@ public class BinaryDictionary extends Dictionary {
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final CharSequence prevWord, final ProximityInfo proximityInfo) {
+ if (!isValidDictionary()) return null;
+ Arrays.fill(mInputCodes, WordComposer.NOT_A_CODE);
+ Arrays.fill(mOutputChars, (char) 0);
+ Arrays.fill(mOutputScores, 0);
if (composer.size() <= 1) {
return TextUtils.isEmpty(prevWord) ? null : getBigramsInternal(composer, prevWord);
} else {
@@ -117,14 +121,9 @@ public class BinaryDictionary extends Dictionary {
// TODO: move to native code
private ArrayList<SuggestedWordInfo> getBigramsInternal(final WordComposer codes,
final CharSequence previousWord) {
- if (!isValidDictionary()) return null;
-
int[] codePoints = StringUtils.toCodePointArray(previousWord.toString());
- Arrays.fill(mOutputChars, (char) 0);
- Arrays.fill(mOutputScores, 0);
int codesSize = codes.size();
- Arrays.fill(mInputCodes, -1);
if (codesSize > 0) {
mInputCodes[0] = codes.getCodeAt(0);
}
@@ -156,10 +155,8 @@ public class BinaryDictionary extends Dictionary {
// proximityInfo and/or prevWordForBigrams may not be null.
private ArrayList<SuggestedWordInfo> getWordsInternal(final WordComposer codes,
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) {
- if (!isValidDictionary()) return null;
-
- final int count = getSuggestions(codes, prevWordForBigrams, proximityInfo, mOutputChars,
- mOutputScores, mSpaceIndices);
+ final int count = getWordsInternalInternal(codes, prevWordForBigrams, proximityInfo,
+ mOutputChars, mOutputScores, mSpaceIndices);
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
for (int j = 0; j < count; ++j) {
@@ -184,13 +181,10 @@ public class BinaryDictionary extends Dictionary {
}
// proximityInfo may not be null.
- private int getSuggestions(final WordComposer codes,
+ // TODO: remove this method by inlining it into getWordsInternal
+ private int getWordsInternalInternal(final WordComposer codes,
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo,
char[] outputChars, int[] scores, int[] spaceIndices) {
- Arrays.fill(mInputCodes, WordComposer.NOT_A_CODE);
- Arrays.fill(outputChars, (char) 0);
- Arrays.fill(scores, 0);
-
final InputPointers ips = codes.getInputPointers();
final boolean isGesture = codes.isBatchMode();
final int codesSize;