aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-07-10 20:21:13 +0900
committerJean Chalard <jchalard@google.com>2012-07-11 11:13:56 +0900
commitb4b93dbf3e0912ba26c5c34abba7a5b94c74138c (patch)
treebeee0b09b1c784e3e58c815182bcbdc8766d79ac /java/src
parent91f7086bf598ee9afb67670b389f0bf0e0e51b57 (diff)
downloadlatinime-b4b93dbf3e0912ba26c5c34abba7a5b94c74138c.tar.gz
latinime-b4b93dbf3e0912ba26c5c34abba7a5b94c74138c.tar.xz
latinime-b4b93dbf3e0912ba26c5c34abba7a5b94c74138c.zip
Pull up common code in the caller (A94)
Change-Id: I84b97886280eca75d5f2b7546f20f8b1bced55bc
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;