diff options
author | 2012-03-13 19:54:56 +0900 | |
---|---|---|
committer | 2012-03-13 19:54:56 +0900 | |
commit | bd4ba23d2b661094d3bd32ee3ef9965775c7d859 (patch) | |
tree | 49d3a15211b956e3113b253c603d656393707954 /java/src/com/android/inputmethod/latin/Suggest.java | |
parent | b5eeb724fc98bb7169683539027d9ba54ffb8b14 (diff) | |
download | latinime-bd4ba23d2b661094d3bd32ee3ef9965775c7d859.tar.gz latinime-bd4ba23d2b661094d3bd32ee3ef9965775c7d859.tar.xz latinime-bd4ba23d2b661094d3bd32ee3ef9965775c7d859.zip |
Some code reorganization.
Use the same local variable inside both branches of an if.
Change-Id: I61f7d506d984f3723ec90604416d1875dd97cd8c
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index fd813c9a2..28cbc9789 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -391,6 +391,7 @@ public class Suggest implements Dictionary.WordCallback { StringUtils.removeDupes(mSuggestions); final SuggestedWords.Builder builder; + final ArrayList<SuggestedWords.SuggestedWordInfo> scoreInfoList; if (DBG) { // TODO: this doesn't take into account the fact that removing dupes from mSuggestions // may have made mScores[] and mSuggestions out of sync. @@ -399,8 +400,7 @@ public class Suggest implements Dictionary.WordCallback { double normalizedScore = BinaryDictionary.calcNormalizedScore( typedWord, autoCorrectionSuggestion.toString(), autoCorrectionSuggestionScore); - ArrayList<SuggestedWords.SuggestedWordInfo> scoreInfoList = - new ArrayList<SuggestedWords.SuggestedWordInfo>(); + scoreInfoList = new ArrayList<SuggestedWords.SuggestedWordInfo>(); scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(autoCorrectionSuggestion, "+", false)); final int suggestionsSize = mSuggestions.size(); @@ -424,13 +424,8 @@ public class Suggest implements Dictionary.WordCallback { scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i), "--", false)); } - builder = new SuggestedWords.Builder(scoreInfoList, allowsToBeAutoCorrected, - false /* isPunctuationSuggestions */); } else { - builder = new SuggestedWords.Builder( - SuggestedWords.Builder.getFromCharSequenceList(mSuggestions), - allowsToBeAutoCorrected, - false /* isPunctuationSuggestions */); + scoreInfoList = SuggestedWords.Builder.getFromCharSequenceList(mSuggestions); } boolean autoCorrectionAvailable = hasAutoCorrection; @@ -440,6 +435,8 @@ public class Suggest implements Dictionary.WordCallback { } // Don't auto-correct words with multiple capital letter autoCorrectionAvailable &= !wordComposer.isMostlyCaps(); + builder = new SuggestedWords.Builder(scoreInfoList, allowsToBeAutoCorrected, + false /* isPunctuationSuggestions */); builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion( autoCorrectionAvailable); if (allowsToBeAutoCorrected && builder.size() > 1 && mAutoCorrectionThreshold > 0 |