diff src/services/anilist.cpp @ 70:64e5f427c6a2

services/anilist: remove unordered_map usage for enum classes for some reason in C++11 unordered_maps don't work on enumerations. so instead we'll just use a switch statement :P
author Paper <mrpapersonic@gmail.com>
date Tue, 03 Oct 2023 04:45:05 -0400
parents 6481c5aed3e1
children 5ccb99bfa605
line wrap: on
line diff
--- a/src/services/anilist.cpp	Tue Oct 03 03:38:25 2023 -0400
+++ b/src/services/anilist.cpp	Tue Oct 03 04:45:05 2023 -0400
@@ -98,20 +98,22 @@
 }
 
 std::string ListStatusToString(const Anime::Anime& anime) {
-	std::unordered_map<Anime::ListStatus, std::string> map = {
-	    {Anime::ListStatus::CURRENT,   "CURRENT"  },
-	    {Anime::ListStatus::PLANNING,  "PLANNING" },
-	    {Anime::ListStatus::COMPLETED, "COMPLETED"},
-	    {Anime::ListStatus::DROPPED,   "DROPPED"  },
-	    {Anime::ListStatus::PAUSED,    "PAUSED"   }
-    };
-
 	if (anime.GetUserIsRewatching())
 		return "REWATCHING";
 
-	if (map.find(anime.GetUserStatus()) == map.end())
-		return "CURRENT";
-	return map[anime.GetUserStatus()];
+	switch (anime.GetUserStatus()) {
+		case Anime::ListStatus::PLANNING:
+			return "PLANNING";
+		case Anime::ListStatus::COMPLETED:
+			return "COMPLETED";
+		case Anime::ListStatus::DROPPED:
+			return "DROPPED";
+		case Anime::ListStatus::PAUSED:
+			return "PAUSED";
+		default:
+			break;
+	}
+	return "CURRENT";
 }
 
 Date ParseDate(const nlohmann::json& json) {