Mercurial > minori
diff src/core/anime_db.cc @ 264:9a04802848c0
*: improve multiple things
e.g. making some strings.cc functions modify strings in-place,
improving m4_ax_have_qt.m4 code, making anime_db.cc rely on
std::optional rather than std::shared_ptr (which was stupid
anyway)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 11 Apr 2024 10:15:57 -0400 |
parents | dd211ff68b36 |
children | 657fda1b9cac |
line wrap: on
line diff
--- a/src/core/anime_db.cc Wed Apr 03 20:46:40 2024 -0400 +++ b/src/core/anime_db.cc Thu Apr 11 10:15:57 2024 -0400 @@ -106,22 +106,6 @@ return (amt > 0) ? std::sqrt(squares_sum / amt) : 0; } -template<typename T, typename U> -static T get_lowest_in_map(const std::unordered_map<T, U>& map) { - if (map.size() <= 0) - return 0; - - T id = 0; - U ret = std::numeric_limits<U>::max(); - for (const auto& t : map) { - if (t.second < ret) { - ret = t.second; - id = t.first; - } - } - return id; -} - /* * TODO: separate this from the anime DB, * provide *some* sort of normalization @@ -130,14 +114,17 @@ if (title.empty()) return 0; + std::string title_n(title); + Strings::NormalizeAnimeTitle(title_n); + for (const auto& [id, anime] : items) { std::vector<std::string> synonyms(anime.GetTitleSynonyms()); synonyms.push_back(anime.GetUserPreferredTitle()); - for (const auto& synonym : synonyms) { - if (synonym == title) { + for (auto& synonym : synonyms) { + Strings::NormalizeAnimeTitle(synonym); + if (synonym == title_n) return id; - } } }