* cache compiled patterns

This commit is contained in:
Reinhard Pointner 2013-12-14 04:11:44 +00:00
parent 0c3406f0b0
commit 59138a3581
1 changed files with 12 additions and 7 deletions

View File

@ -193,7 +193,7 @@ public class ReleaseInfo {
} }
} }
} }
volumeRoots = volumes; volumeRoots = unmodifiableSet(volumes);
} }
return volumeRoots; return volumeRoots;
} }
@ -271,15 +271,20 @@ public class ReleaseInfo {
return anidbIndexResource.get(); return anidbIndexResource.get();
} }
private Map<Pattern, String> seriesDirectMappings;
public Map<Pattern, String> getSeriesDirectMappings() throws IOException { public Map<Pattern, String> getSeriesDirectMappings() throws IOException {
Map<Pattern, String> mappings = new LinkedHashMap<Pattern, String>(); if (seriesDirectMappings == null) {
for (String line : seriesDirectMappingsResource.get()) { Map<Pattern, String> mappings = new LinkedHashMap<Pattern, String>();
String[] tsv = line.split("\t", 2); for (String line : seriesDirectMappingsResource.get()) {
if (tsv.length == 2) { String[] tsv = line.split("\t", 2);
mappings.put(compile("(?<!\\p{Alnum})(" + tsv[0] + ")(?!\\p{Alnum})", CASE_INSENSITIVE | UNICODE_CASE), tsv[1]); if (tsv.length == 2) {
mappings.put(compile("(?<!\\p{Alnum})(" + tsv[0] + ")(?!\\p{Alnum})", CASE_INSENSITIVE | UNICODE_CASE), tsv[1]);
}
} }
seriesDirectMappings = unmodifiableMap(mappings);
} }
return mappings; return seriesDirectMappings;
} }
public FileFilter getDiskFolderFilter() { public FileFilter getDiskFolderFilter() {