mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 06:20:27 -04:00
Refactor, Streamify
This commit is contained in:
parent
4e1f7104d0
commit
ae989ee990
@ -81,18 +81,12 @@ public class CommonSequenceMatcher {
|
|||||||
return getCollationKeys(SPACE.split(sequence));
|
return getCollationKeys(SPACE.split(sequence));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<String, CollationKey> collationKeyDictionary = synchronizedMap(new HashMap<String, CollationKey>(256));
|
private final Map<String, CollationKey> collationKeyDictionary = synchronizedMap(new HashMap<String, CollationKey>(64, 4));
|
||||||
|
|
||||||
protected CollationKey[] getCollationKeys(String[] words) {
|
protected CollationKey[] getCollationKeys(String[] words) {
|
||||||
CollationKey[] keys = new CollationKey[words.length];
|
return stream(words).map(w -> {
|
||||||
for (int i = 0; i < keys.length; i++) {
|
return collationKeyDictionary.computeIfAbsent(w, collator::getCollationKey);
|
||||||
keys[i] = collationKeyDictionary.get(words[i]);
|
}).toArray(CollationKey[]::new);
|
||||||
if (keys[i] == null) {
|
|
||||||
keys[i] = collator.getCollationKey(words[i]);
|
|
||||||
collationKeyDictionary.put(words[i], keys[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return keys;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <E extends Comparable<E>> E[] firstCommonSequence(E[] seq1, E[] seq2, int maxStartIndex, boolean returnFirstMatch) {
|
protected <E extends Comparable<E>> E[] firstCommonSequence(E[] seq1, E[] seq2, int maxStartIndex, boolean returnFirstMatch) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user