diff options
author | 2011-08-17 18:26:45 +0900 | |
---|---|---|
committer | 2011-08-18 15:16:59 +0900 | |
commit | 3016863f86279d0be04c0285fefce6861415f242 (patch) | |
tree | 2ea25770db8f5c010356e2f25f68cd60b19b58ef /java/src | |
parent | 961453c3b3a8eb3aefb2cebdbcc315c98c2abbd4 (diff) | |
download | latinime-3016863f86279d0be04c0285fefce6861415f242.tar.gz latinime-3016863f86279d0be04c0285fefce6861415f242.tar.xz latinime-3016863f86279d0be04c0285fefce6861415f242.zip |
Refactor string removal to make it static
The next step is to move this over to the Utils class.
The ultimate goal is to make use of the duplicate removal code
also in the spell checker as per
Bug: 5175740
Change-Id: Ica36691b843b0713b832c56ffc65e5b2ec427c4a
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index a2d66f398..937457ee2 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -426,7 +426,7 @@ public class Suggest implements Dictionary.WordCallback { if (typedWord != null) { mSuggestions.add(0, typedWordString); } - removeDupes(); + removeDupes(mSuggestions); if (DBG) { double normalizedScore = mAutoCorrection.getNormalizedScore(); @@ -453,8 +453,7 @@ public class Suggest implements Dictionary.WordCallback { return new SuggestedWords.Builder().addWords(mSuggestions, null); } - private void removeDupes() { - final ArrayList<CharSequence> suggestions = mSuggestions; + private static void removeDupes(final ArrayList<CharSequence> suggestions) { if (suggestions.size() < 2) return; int i = 1; // Don't cache suggestions.size(), since we may be removing items @@ -464,7 +463,7 @@ public class Suggest implements Dictionary.WordCallback { for (int j = 0; j < i; j++) { CharSequence previous = suggestions.get(j); if (TextUtils.equals(cur, previous)) { - removeFromSuggestions(i); + removeFromSuggestions(suggestions, i); i--; break; } @@ -473,10 +472,12 @@ public class Suggest implements Dictionary.WordCallback { } } - private void removeFromSuggestions(int index) { - CharSequence garbage = mSuggestions.remove(index); + private static void removeFromSuggestions(final ArrayList<CharSequence> suggestions, + final int index) { + final CharSequence garbage = suggestions.remove(index); if (garbage != null && garbage instanceof StringBuilder) { - mStringPool.add(garbage); + // TODO: rebase this over the static string builder pool + // mStringPool.add(garbage); } } |