Pull up common code in the caller (A94)
Change-Id: I84b97886280eca75d5f2b7546f20f8b1bced55bcmain
parent
91f7086bf5
commit
b4b93dbf3e
|
@ -107,6 +107,10 @@ public class BinaryDictionary extends Dictionary {
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
|
||||||
final CharSequence prevWord, final ProximityInfo proximityInfo) {
|
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) {
|
if (composer.size() <= 1) {
|
||||||
return TextUtils.isEmpty(prevWord) ? null : getBigramsInternal(composer, prevWord);
|
return TextUtils.isEmpty(prevWord) ? null : getBigramsInternal(composer, prevWord);
|
||||||
} else {
|
} else {
|
||||||
|
@ -117,14 +121,9 @@ public class BinaryDictionary extends Dictionary {
|
||||||
// TODO: move to native code
|
// TODO: move to native code
|
||||||
private ArrayList<SuggestedWordInfo> getBigramsInternal(final WordComposer codes,
|
private ArrayList<SuggestedWordInfo> getBigramsInternal(final WordComposer codes,
|
||||||
final CharSequence previousWord) {
|
final CharSequence previousWord) {
|
||||||
if (!isValidDictionary()) return null;
|
|
||||||
|
|
||||||
int[] codePoints = StringUtils.toCodePointArray(previousWord.toString());
|
int[] codePoints = StringUtils.toCodePointArray(previousWord.toString());
|
||||||
Arrays.fill(mOutputChars, (char) 0);
|
|
||||||
Arrays.fill(mOutputScores, 0);
|
|
||||||
|
|
||||||
int codesSize = codes.size();
|
int codesSize = codes.size();
|
||||||
Arrays.fill(mInputCodes, -1);
|
|
||||||
if (codesSize > 0) {
|
if (codesSize > 0) {
|
||||||
mInputCodes[0] = codes.getCodeAt(0);
|
mInputCodes[0] = codes.getCodeAt(0);
|
||||||
}
|
}
|
||||||
|
@ -156,10 +155,8 @@ public class BinaryDictionary extends Dictionary {
|
||||||
// proximityInfo and/or prevWordForBigrams may not be null.
|
// proximityInfo and/or prevWordForBigrams may not be null.
|
||||||
private ArrayList<SuggestedWordInfo> getWordsInternal(final WordComposer codes,
|
private ArrayList<SuggestedWordInfo> getWordsInternal(final WordComposer codes,
|
||||||
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) {
|
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) {
|
||||||
if (!isValidDictionary()) return null;
|
final int count = getWordsInternalInternal(codes, prevWordForBigrams, proximityInfo,
|
||||||
|
mOutputChars, mOutputScores, mSpaceIndices);
|
||||||
final int count = getSuggestions(codes, prevWordForBigrams, proximityInfo, mOutputChars,
|
|
||||||
mOutputScores, mSpaceIndices);
|
|
||||||
|
|
||||||
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
|
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>();
|
||||||
for (int j = 0; j < count; ++j) {
|
for (int j = 0; j < count; ++j) {
|
||||||
|
@ -184,13 +181,10 @@ public class BinaryDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
// proximityInfo may not be null.
|
// 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,
|
final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo,
|
||||||
char[] outputChars, int[] scores, int[] spaceIndices) {
|
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 InputPointers ips = codes.getInputPointers();
|
||||||
final boolean isGesture = codes.isBatchMode();
|
final boolean isGesture = codes.isBatchMode();
|
||||||
final int codesSize;
|
final int codesSize;
|
||||||
|
|
Loading…
Reference in New Issue