diff options
author | 2012-03-14 18:35:07 +0900 | |
---|---|---|
committer | 2012-03-14 18:35:07 +0900 | |
commit | ac5e463402f7c15a941a5eda93e9576c2a904f1c (patch) | |
tree | 32a741776bd098194b96439ad7b0122ff1fac5d8 /java/src/com/android/inputmethod/latin/Suggest.java | |
parent | def4551c2a570e7f575b2e9303506d790c2f335f (diff) | |
download | latinime-ac5e463402f7c15a941a5eda93e9576c2a904f1c.tar.gz latinime-ac5e463402f7c15a941a5eda93e9576c2a904f1c.tar.xz latinime-ac5e463402f7c15a941a5eda93e9576c2a904f1c.zip |
Minor optimization
We know the size in advance, this may save a few allocations
Change-Id: I2fb9a725f34ba2da4f34ed335652f10447d5d166
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 16dd75610..19b6c0b31 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -400,10 +400,9 @@ public class Suggest implements Dictionary.WordCallback { final CharSequence autoCorrectionSuggestion = mSuggestions.get(0); double normalizedScore = BinaryDictionary.calcNormalizedScore( typedWord, autoCorrectionSuggestion.toString(), mScores[0]); - suggestionsList = new ArrayList<SuggestedWordInfo>(); - suggestionsList.add(new SuggestedWordInfo(autoCorrectionSuggestion, "+", - false)); final int suggestionsSize = mSuggestions.size(); + suggestionsList = new ArrayList<SuggestedWordInfo>(suggestionsSize); + suggestionsList.add(new SuggestedWordInfo(autoCorrectionSuggestion, "+", false)); // Note: i here is the index in mScores[], but the index in mSuggestions is one more // than i because we added the typed word to mSuggestions without touching mScores. for (int i = 0; i < mScores.length && i < suggestionsSize - 1; ++i) { |