Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac5e4634 authored by Jean Chalard's avatar Jean Chalard
Browse files

Minor optimization

We know the size in advance, this may save a few allocations

Change-Id: I2fb9a725f34ba2da4f34ed335652f10447d5d166
parent def4551c
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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) {