Simplify MALdiff function

This commit is contained in:
Eduard Urbach 2018-04-26 19:39:43 +02:00
parent e178e84f8b
commit b6b6f22af6

View File

@ -98,6 +98,27 @@ func compare(animes []*arn.Anime) []*utils.MALComparison {
}
malAnime := obj.(*mal.Anime)
differences := diff(anime, malAnime)
// Add if there were any differences
if len(differences) > 0 {
comparisons = append(comparisons, &utils.MALComparison{
Anime: anime,
MALAnime: malAnime,
Differences: differences,
})
if len(comparisons) >= maxCompareMALEntries {
break
}
}
}
return comparisons
}
// diff returns all the differences between an anime and its MAL counterpart.
func diff(anime *arn.Anime, malAnime *mal.Anime) []animediff.Difference {
var differences []animediff.Difference
// Canonical title
@ -218,19 +239,5 @@ func compare(animes []*arn.Anime) []*utils.MALComparison {
}
}
// Add if there were any differences
if len(differences) > 0 {
comparisons = append(comparisons, &utils.MALComparison{
Anime: anime,
MALAnime: malAnime,
Differences: differences,
})
if len(comparisons) >= maxCompareMALEntries {
break
}
}
}
return comparisons
return differences
}