diff options
author | 2014-06-26 09:30:16 +0000 | |
---|---|---|
committer | 2014-06-24 01:59:00 +0000 | |
commit | 90759f2ab77e9bb6a47b59e6de89318516a65393 (patch) | |
tree | a6efccc32b05556ff81a80a817d0f88e3feec484 /java/src/com/android/inputmethod/latin/SuggestedWords.java | |
parent | 8d3d0f3b847359929bc5cfb90aff077c0c9e6854 (diff) | |
parent | b740886aeb47f8f3fb32bca7a7faa13d5756bd74 (diff) | |
download | latinime-90759f2ab77e9bb6a47b59e6de89318516a65393.tar.gz latinime-90759f2ab77e9bb6a47b59e6de89318516a65393.tar.xz latinime-90759f2ab77e9bb6a47b59e6de89318516a65393.zip |
Merge "[CS4] Remove useless tests and processing"
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; } } |