diff src/core/anime_db.cc @ 198:bc1ae1810855

dep/animia: switch from using classes to global functions the old idea was ok, but sort of hackish; this method doesn't use classes at all, and this way (especially important!) we can do wayland stuff AND x11 at the same time, which wasn't really possible without stupid workarounds in the other method
author Paper <mrpapersonic@gmail.com>
date Sun, 24 Dec 2023 02:59:42 -0500
parents c4ca035c565d
children 4d461ef7d424
line wrap: on
line diff
--- a/src/core/anime_db.cc	Fri Dec 08 11:19:54 2023 -0500
+++ b/src/core/anime_db.cc	Sun Dec 24 02:59:42 2023 -0500
@@ -122,29 +122,29 @@
 	return id;
 }
 
-/* This is really fugly but WHO CARES :P
-
-   This fairly basic algorithm is only in effect because
-   there are some special cases, e.g. Another and Re:ZERO, where 
-   we get the wrong match, so we have to create Advanced Techniques
-   to solve this
-
-   This algorithm:
-     1. searches each anime item for a match to the preferred title
-        AND all synonyms and marks those matches with
-          `synonym.length() - (synonym.find(needle) + needle.length());`
-        which should never be less than zero and will be zero if, and only if
-        the titles match exactly.
-     2. returns the id of the match that is the lowest, which will most
-        definitely match anything that exactly matches the title of the
-        filename */
+/* 
+ * This fairly basic algorithm is only in effect because
+ * there are some special cases, e.g. Another and Re:ZERO, where 
+ * we get the wrong match, so we have to create Advanced Techniques
+ * to solve this
+ *
+ * This algorithm:
+ *   1. searches each anime item for a match to the preferred title
+ *      AND all synonyms and marks those matches with
+ *        `synonym.length() - (synonym.find(needle) + needle.length());`
+ *      which should never be less than zero and will be zero if, and only if
+ *      the titles match exactly.
+ *   2. returns the id of the match that is the lowest, which will most
+ *      definitely match anything that exactly matches the title of the
+ *      filename
+*/
 int Database::GetAnimeFromTitle(const std::string& title) {
 	if (title.empty())
 		return 0;
 
 	std::unordered_map<int, size_t> map;
 
-	auto process_title = [&map](const Anime& anime, const std::string& title, const std::string& needle) -> bool {
+	static const auto process_title = [&map](const Anime& anime, const std::string& title, const std::string& needle) -> bool {
 		size_t ret = title.find(needle);
 		if (ret == std::string::npos)
 			return false;