Reduction, step 8

Change-Id: I54334039597e235e24f169e34c1d44109180ee88
main
Jean Chalard 2012-03-09 18:36:07 +09:00
parent a333ff19ef
commit 0cf422fbb7
2 changed files with 16 additions and 16 deletions

View File

@ -2038,7 +2038,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) { if (mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(), final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
mSettingsValues.mWordSeparators); mSettingsValues.mWordSeparators);
builder = mSuggest.getBigramPredictionWordBuilder(prevWord); if (!TextUtils.isEmpty(prevWord)) {
builder = mSuggest.getBigramPredictionWordBuilder(prevWord);
} else {
builder = null;
}
} else { } else {
builder = null; builder = null;
} }

View File

@ -276,21 +276,17 @@ public class Suggest implements Dictionary.WordCallback {
Arrays.fill(mBigramScores, 0); Arrays.fill(mBigramScores, 0);
collectGarbage(mBigramSuggestions, PREF_MAX_BIGRAMS); collectGarbage(mBigramSuggestions, PREF_MAX_BIGRAMS);
// Note that if prevWordForBigram is empty, we'll always return the same empty CharSequence lowerPrevWord = prevWordForBigram.toString().toLowerCase();
// SuggestedWords.Builder if (mMainDict != null && mMainDict.isValidWord(lowerPrevWord)) {
if (!TextUtils.isEmpty(prevWordForBigram)) { prevWordForBigram = lowerPrevWord;
CharSequence lowerPrevWord = prevWordForBigram.toString().toLowerCase(); }
if (mMainDict != null && mMainDict.isValidWord(lowerPrevWord)) { for (final Dictionary dictionary : mBigramDictionaries.values()) {
prevWordForBigram = lowerPrevWord; dictionary.getBigrams(sEmptyWordComposer, prevWordForBigram, this);
} }
for (final Dictionary dictionary : mBigramDictionaries.values()) { // Nothing entered: return all bigrams for the previous word
dictionary.getBigrams(sEmptyWordComposer, prevWordForBigram, this); int insertCount = Math.min(mBigramSuggestions.size(), mPrefMaxSuggestions);
} for (int i = 0; i < insertCount; ++i) {
// Nothing entered: return all bigrams for the previous word addBigramToSuggestions(mBigramSuggestions.get(i));
int insertCount = Math.min(mBigramSuggestions.size(), mPrefMaxSuggestions);
for (int i = 0; i < insertCount; ++i) {
addBigramToSuggestions(mBigramSuggestions.get(i));
}
} }
StringUtils.removeDupes(mSuggestions); StringUtils.removeDupes(mSuggestions);