Small optimization
We only use some of those results in one branch of an if() test. Let's not compute those that are not needed. Change-Id: I6ca068646b86d2980fb88e75b110ad077362c4ff
This commit is contained in:
parent
195419b1ec
commit
91e55ac000
1 changed files with 7 additions and 7 deletions
|
@ -1823,7 +1823,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(mWordComposer,
|
||||
prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), mCorrectionMode);
|
||||
|
||||
boolean autoCorrectionAvailable = mSuggest.hasAutoCorrection();
|
||||
// Here, we want to promote a whitelisted word if exists.
|
||||
// TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid"
|
||||
// but still autocorrected from - in the case the whitelist only capitalizes the word.
|
||||
|
@ -1840,12 +1839,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
quotesCount > 0
|
||||
? typedWord.subSequence(0, typedWord.length() - quotesCount) : typedWord,
|
||||
preferCapitalization());
|
||||
if (mCorrectionMode == Suggest.CORRECTION_FULL
|
||||
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
||||
autoCorrectionAvailable |= (!allowsToBeAutoCorrected);
|
||||
}
|
||||
// Don't auto-correct words with multiple capital letter
|
||||
autoCorrectionAvailable &= !mWordComposer.isMostlyCaps();
|
||||
|
||||
// Basically, we update the suggestion strip only when suggestion count > 1. However,
|
||||
// there is an exception: We update the suggestion strip whenever typed word's length
|
||||
|
@ -1855,6 +1848,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
// length == 1).
|
||||
if (builder.size() > 1 || typedWord.length() == 1 || (!allowsToBeAutoCorrected)
|
||||
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
|
||||
boolean autoCorrectionAvailable = mSuggest.hasAutoCorrection();
|
||||
if (mCorrectionMode == Suggest.CORRECTION_FULL
|
||||
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
||||
autoCorrectionAvailable |= (!allowsToBeAutoCorrected);
|
||||
}
|
||||
// Don't auto-correct words with multiple capital letter
|
||||
autoCorrectionAvailable &= !mWordComposer.isMostlyCaps();
|
||||
builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion(
|
||||
autoCorrectionAvailable);
|
||||
if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, mSuggest,
|
||||
|
|
Loading…
Reference in a new issue