diff options
author | 2014-06-19 16:27:04 +0900 | |
---|---|---|
committer | 2014-06-26 18:26:08 +0900 | |
commit | b740886aeb47f8f3fb32bca7a7faa13d5756bd74 (patch) | |
tree | 01488a65f38d1369a1973dae395566a095d9a53f /java/src/com/android/inputmethod/latin/SuggestedWords.java | |
parent | 5961f2dfaca123e8e6f2fab33fb9d23d8b4c98fc (diff) | |
download | latinime-b740886aeb47f8f3fb32bca7a7faa13d5756bd74.tar.gz latinime-b740886aeb47f8f3fb32bca7a7faa13d5756bd74.tar.xz latinime-b740886aeb47f8f3fb32bca7a7faa13d5756bd74.zip |
[CS4] Remove useless tests and processing
Since we have a de-duped and transformed collection, we
can just read from it instead of computing it separately.
Bug: 13238601
Change-Id: I0aa4b0d91d3b350f9449e13658bfb587fc538764
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/SuggestedWords.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index f22af7991..e587b18c9 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -330,29 +330,37 @@ public class SuggestedWords { } // This will always remove the higher index if a duplicate is found. - public static void removeDups(final String typedWord, + public static boolean removeDups(final String typedWord, ArrayList<SuggestedWordInfo> candidates) { if (candidates.isEmpty()) { - return; + return false; } + final boolean didRemoveTypedWord; if (!TextUtils.isEmpty(typedWord)) { - removeSuggestedWordInfoFrom(typedWord, candidates, -1 /* startIndexExclusive */); + didRemoveTypedWord = removeSuggestedWordInfoFrom(typedWord, candidates, + -1 /* startIndexExclusive */); + } else { + didRemoveTypedWord = false; } for (int i = 0; i < candidates.size(); ++i) { removeSuggestedWordInfoFrom(candidates.get(i).mWord, candidates, i /* startIndexExclusive */); } + return didRemoveTypedWord; } - private static void removeSuggestedWordInfoFrom(final String word, + private static boolean removeSuggestedWordInfoFrom(final String word, final ArrayList<SuggestedWordInfo> candidates, final int startIndexExclusive) { + boolean didRemove = false; for (int i = startIndexExclusive + 1; i < candidates.size(); ++i) { final SuggestedWordInfo previous = candidates.get(i); if (word.equals(previous.mWord)) { + didRemove = true; candidates.remove(i); --i; } } + return didRemove; } } |