]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Do not needlessly use Linked variants of HashSet/HashMap.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 29 Oct 2016 21:43:01 +0000 (23:43 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sat, 29 Oct 2016 21:43:01 +0000 (23:43 +0200)
src/com/hughes/android/dictionary/DictionaryApplication.java
src/com/hughes/android/dictionary/engine/Index.java
src/com/hughes/android/dictionary/engine/Language.java

index f23f7340f9dc0e554b0902c02723a1e5e8eda16d..5d1ca0ecc33d283f2668b940454d5669d6c81972 100644 (file)
@@ -53,7 +53,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -113,7 +113,7 @@ public class DictionaryApplication extends Application {
 
     // Useful:
     // http://www.loc.gov/standards/iso639-2/php/code_list.php
-    public static final Map<String, LanguageResources> isoCodeToResources = new LinkedHashMap<String, LanguageResources>();
+    public static final Map<String, LanguageResources> isoCodeToResources = new HashMap<String, LanguageResources>();
     static {
         isoCodeToResources.put("AF", new LanguageResources("Afrikaans", R.string.AF,
                 R.drawable.flag_of_south_africa));
@@ -282,7 +282,7 @@ public class DictionaryApplication extends Application {
         // present.
         final List<String> dictionaryFilesOrdered = new ArrayList<String>();
 
-        final Map<String, DictionaryInfo> uncompressedFilenameToDictionaryInfo = new LinkedHashMap<String, DictionaryInfo>();
+        final Map<String, DictionaryInfo> uncompressedFilenameToDictionaryInfo = new HashMap<String, DictionaryInfo>();
 
         /**
          * Sometimes a deserialized version of this data structure isn't valid.
@@ -301,7 +301,7 @@ public class DictionaryApplication extends Application {
         if (DOWNLOADABLE_UNCOMPRESSED_FILENAME_NAME_TO_DICTIONARY_INFO != null) {
             return;
         }
-        DOWNLOADABLE_UNCOMPRESSED_FILENAME_NAME_TO_DICTIONARY_INFO = new LinkedHashMap<String, DictionaryInfo>();
+        DOWNLOADABLE_UNCOMPRESSED_FILENAME_NAME_TO_DICTIONARY_INFO = new HashMap<String, DictionaryInfo>();
         final BufferedReader reader = new BufferedReader(
                 new InputStreamReader(context.getResources().openRawResource(R.raw.dictionary_info)));
         try {
@@ -481,7 +481,7 @@ public class DictionaryApplication extends Application {
 
     String defaultLangISO2 = Locale.getDefault().getLanguage().toLowerCase();
     String defaultLangName = null;
-    final Map<String, String> fileToNameCache = new LinkedHashMap<String, String>();
+    final Map<String, String> fileToNameCache = new HashMap<String, String>();
 
     public String isoCodeToLocalizedLanguageName(final String isoCode) {
         final Language.LanguageResources languageResources = isoCodeToResources
@@ -716,7 +716,7 @@ public class DictionaryApplication extends Application {
         final List<DictionaryInfo> result = new ArrayList<DictionaryInfo>(
                 dictionaryConfig.dictionaryFilesOrdered.size());
 
-        final Map<String, DictionaryInfo> remaining = new LinkedHashMap<String, DictionaryInfo>(
+        final Map<String, DictionaryInfo> remaining = new HashMap<String, DictionaryInfo>(
                 DOWNLOADABLE_UNCOMPRESSED_FILENAME_NAME_TO_DICTIONARY_INFO);
         remaining.keySet().removeAll(dictionaryConfig.dictionaryFilesOrdered);
         for (final DictionaryInfo dictionaryInfo : remaining.values()) {
index 65b8e970906eb0d9a2b73d54090a23aedab14ca4..a664ce5f1d506d63798eaff82d7681790c251459 100644 (file)
@@ -44,8 +44,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.EnumMap;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -344,7 +343,7 @@ public final class Index implements RAFSerializable<Index> {
 
     private static final int MAX_SEARCH_ROWS = 1000;
 
-    private final Map<String, Integer> prefixToNumRows = new LinkedHashMap<String, Integer>();
+    private final Map<String, Integer> prefixToNumRows = new HashMap<String, Integer>();
 
     private synchronized final int getUpperBoundOnRowsStartingWith(final String normalizedPrefix,
             final int maxRows, final AtomicBoolean interrupted) {
@@ -379,7 +378,7 @@ public final class Index implements RAFSerializable<Index> {
         final long startMills = System.currentTimeMillis();
         final List<RowBase> result = new ArrayList<RowBase>();
 
-        final Set<String> normalizedNonStoplist = new LinkedHashSet<String>();
+        final Set<String> normalizedNonStoplist = new HashSet<String>();
 
         String bestPrefix = null;
         int leastRows = Integer.MAX_VALUE;
index 007ad4b6e16293906fbb6188aa5986b43a0c9ba8..48ab242ada0ea0270be8b63a783c7a4a1979665f 100644 (file)
@@ -18,7 +18,7 @@ import com.hughes.android.dictionary.DictionaryApplication;
 import java.text.Collator;
 
 import java.util.Comparator;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.regex.Pattern;
@@ -41,7 +41,7 @@ public class Language {
         }
     }
 
-    private static final Map<String, Language> registry = new LinkedHashMap<String, Language>();
+    private static final Map<String, Language> registry = new HashMap<String, Language>();
 
     final String isoCode;
     final Locale locale;