From bdc81b35019c8b903933f28744a33c484f0d7b94 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 23 Aug 2016 00:51:47 +0800 Subject: [PATCH] Fix inconsistent SubstringFields metric behaviour --- source/net/filebot/similarity/EpisodeMetrics.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/similarity/EpisodeMetrics.java b/source/net/filebot/similarity/EpisodeMetrics.java index f49a8d2e..5f372cf6 100644 --- a/source/net/filebot/similarity/EpisodeMetrics.java +++ b/source/net/filebot/similarity/EpisodeMetrics.java @@ -208,10 +208,13 @@ public enum EpisodeMetrics implements SimilarityMetric { return stream(objects).map(EpisodeMetrics::normalizeObject).toArray(String[]::new); } + protected static final int MAX_FIELDS = 5; + protected Object[] fields(Object object) { if (object instanceof Episode) { Episode e = (Episode) object; - return StreamEx.of(e.getSeriesName(), e.getTitle()).append(e.getSeriesNames()).filter(Objects::nonNull).map(Normalization::removeTrailingBrackets).distinct().limit(5).toArray(); + Object[] names = StreamEx.of(e.getSeriesName(), e.getTitle()).append(e.getSeriesNames()).filter(Objects::nonNull).map(Normalization::removeTrailingBrackets).distinct().limit(MAX_FIELDS).toArray(); + return copyOf(names, MAX_FIELDS); } if (object instanceof File) {