From 5110e2cb5115bc7d8337a63427b895eeb74c9cd5 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 28 Jun 2012 15:20:52 +0900 Subject: [PATCH] Optimization (A8) Change-Id: I2b9e8cc6a13fd9af84a5189e4d3fbb2b05c68d46 --- .../android/inputmethod/latin/Suggest.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index f4f82f9c5..b02de9a4a 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -245,13 +245,20 @@ public class Suggest { final ArrayList suggestionsContainer = new ArrayList(suggestionsSet); - for (int i = 0; i < suggestionsContainer.size(); ++i) { + final int suggestionsCount = suggestionsContainer.size(); + if (isFirstCharCapitalized || isAllUpperCase || 0 != trailingSingleQuotesCount) { + for (int i = 0; i < suggestionsCount; ++i) { + final SuggestedWordInfo wordInfo = suggestionsContainer.get(i); + final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo( + wordInfo, mLocale, isAllUpperCase, isFirstCharCapitalized, + trailingSingleQuotesCount); + suggestionsContainer.set(i, transformedWordInfo); + } + } + + for (int i = 0; i < suggestionsCount; ++i) { final SuggestedWordInfo wordInfo = suggestionsContainer.get(i); - final SuggestedWordInfo transformedWordInfo = getTransformedSuggestedWordInfo(wordInfo, - mLocale, isAllUpperCase, isFirstCharCapitalized, trailingSingleQuotesCount); - suggestionsContainer.set(i, transformedWordInfo); - LatinImeLogger.onAddSuggestedWord(transformedWordInfo.mWord.toString(), - transformedWordInfo.mSourceDict); + LatinImeLogger.onAddSuggestedWord(wordInfo.mWord.toString(), wordInfo.mSourceDict); } if (!isPrediction) { @@ -347,9 +354,6 @@ public class Suggest { private static SuggestedWordInfo getTransformedSuggestedWordInfo( final SuggestedWordInfo wordInfo, final Locale locale, final boolean isAllUpperCase, final boolean isFirstCharCapitalized, final int trailingSingleQuotesCount) { - if (!isFirstCharCapitalized && !isAllUpperCase && 0 == trailingSingleQuotesCount) { - return wordInfo; - } final StringBuilder sb = new StringBuilder(getApproxMaxWordLength()); if (isAllUpperCase) { sb.append(wordInfo.mWord.toString().toUpperCase(locale));