From 3ecb2747b3b46991a0fb8e1573d689611ecbd1cc Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 27 Jun 2012 18:28:35 +0900 Subject: [PATCH] Optimization. It's useless to do this for all suggestions including those that will be ousted from the list. Change-Id: I7bd63d783e21984a269e4b1ae17e9b9d8c0859e3 --- .../com/android/inputmethod/latin/Suggest.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 389d4e215..de05ed60e 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -250,6 +250,15 @@ public class Suggest { } } + for (int i = 0; i < suggestionsContainer.size(); ++i) { + final SuggestedWordInfo wordInfo = suggestionsContainer.get(i); + final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo(wordInfo, + mLocale, mIsAllUpperCase, mIsFirstCharCapitalized, mTrailingSingleQuotesCount); + suggestionsContainer.set(i, transformedWordInfo); + LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(), + transformedWordInfo.mSourceDict); + } + final CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized, mWhiteListDictionary.getWhitelistedWord(consideredWord)); @@ -370,7 +379,7 @@ public class Suggest { private static final SuggestedWordInfoComparator sSuggestedWordInfoComparator = new SuggestedWordInfoComparator(); - public void addWord(final SuggestedWordInfo wordInfo, + private static void addWord(final SuggestedWordInfo wordInfo, final ArrayList suggestions) { final int index = Collections.binarySearch(suggestions, wordInfo, sSuggestedWordInfoComparator); @@ -378,15 +387,10 @@ public class Suggest { // it returns -insertionPoint - 1. We want the insertion point, so: final int pos = index >= 0 ? index : -index - 1; if (pos >= MAX_SUGGESTIONS) return; - - final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo(wordInfo, - mLocale, mIsAllUpperCase, mIsFirstCharCapitalized, mTrailingSingleQuotesCount); - suggestions.add(pos, transformedWordInfo); + suggestions.add(pos, wordInfo); if (suggestions.size() > MAX_SUGGESTIONS) { suggestions.remove(MAX_SUGGESTIONS); } - LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(), - transformedWordInfo.mSourceDict); } private static SuggestedWordInfo getTransformedSuggestedWordInfo(