From 0dc422e0c7bbb5f2f5ea52dc87e3caf36b545e6b Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 6 Jun 2013 15:52:13 +0900 Subject: [PATCH] Use an iterator to remove stuff from an ArrayList. Silly me >.> Bug: 9306154 Change-Id: Ic00e9d6a31cd1d7aacefe68b7be9c2199e297b0d --- .../inputmethod/latin/DictionaryInfoUtils.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java index df7bad8d0..9d478491a 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java @@ -30,6 +30,7 @@ import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Iterator; import java.util.Locale; /** @@ -301,12 +302,14 @@ public class DictionaryInfoUtils { private static void addOrUpdateDictInfo(final ArrayList dictList, final DictionaryInfo newElement) { - for (final DictionaryInfo info : dictList) { - if (info.mLocale.equals(newElement.mLocale)) { - if (newElement.mVersion <= info.mVersion) { + final Iterator iter = dictList.iterator(); + while (iter.hasNext()) { + final DictionaryInfo thisDictInfo = iter.next(); + if (thisDictInfo.mLocale.equals(newElement.mLocale)) { + if (newElement.mVersion <= thisDictInfo.mVersion) { return; } - dictList.remove(info); + iter.remove(); } } dictList.add(newElement);