Simplify std::find with Common::Contains

In NandPaths.cpp, the `std::initializer_list<char>` of illegal characters has been turned into a `char[]` (similar to the one in GameList.cpp).

The reverse iteration in ResourcePack.cpp seemed to provide no benefits, and doing without it it seemed to have no ill effects.
This commit is contained in:
mitaclaw
2024-09-20 22:17:29 -07:00
parent 6f10acea3f
commit 110d32729e
16 changed files with 43 additions and 51 deletions

View File

@ -11,6 +11,7 @@
#include <fmt/ranges.h>
#include "Common/CommonTypes.h"
#include "Common/Contains.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
@ -105,9 +106,8 @@ bool IsTitlePath(const std::string& path, std::optional<FromWhichRoot> from, u64
static bool IsIllegalCharacter(char c)
{
static constexpr auto illegal_chars = {'\"', '*', '/', ':', '<', '>', '?', '\\', '|', '\x7f'};
return static_cast<unsigned char>(c) <= 0x1F ||
std::find(illegal_chars.begin(), illegal_chars.end(), c) != illegal_chars.end();
static constexpr char illegal_chars[] = {'\"', '*', '/', ':', '<', '>', '?', '\\', '|', '\x7f'};
return static_cast<unsigned char>(c) <= 0x1F || Common::Contains(illegal_chars, c);
}
std::string EscapeFileName(const std::string& filename)