From c7bfcd499e7f3f0fe3bb30251c9ce61dd81d6b4e Mon Sep 17 00:00:00 2001 From: Nauta Turbidus <88062389+nauta-turbidus@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:49:39 +0200 Subject: [PATCH] Refactor to utilize std::stringview::substr() --- src/content/subgames.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp index fc57dd256..28b3f098d 100644 --- a/src/content/subgames.cpp +++ b/src/content/subgames.cpp @@ -175,18 +175,14 @@ SubgameSpec findSubgame(const std::string &id) found_alias(); break; // Make sure a "_game" suffix is ignored - } else if (str_ends_with(alias, "_game")) { - std::string_view alias_trimmed{alias.data(), alias.size() - 5}; - if (alias_trimmed == id) { + } else if (str_ends_with(alias, "_game") + && alias.substr(0, alias.size() - 5) == id) { found_alias(); break; - } - } else if (str_ends_with(id, "_game")) { - std::string_view id_trimmed{id.data(), id.size() - 5}; - if (id_trimmed == alias) { + } else if (str_ends_with(id, "_game") + && id.substr(0, id.size() - 5) == alias) { found_alias(); break; - } } } }