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

@ -21,6 +21,7 @@
#include "Common/CPUDetect.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/Contains.h"
#include "Common/Crypto/SHA1.h"
#include "Common/FileUtil.h"
#include "Common/Hash.h"
@ -453,21 +454,18 @@ std::vector<Partition> VolumeVerifier::CheckPartitions()
types.emplace_back(*type);
}
if (std::find(types.cbegin(), types.cend(), PARTITION_UPDATE) == types.cend())
if (!Common::Contains(types, PARTITION_UPDATE))
AddProblem(Severity::Low, Common::GetStringT("The update partition is missing."));
const bool has_data_partition =
std::find(types.cbegin(), types.cend(), PARTITION_DATA) != types.cend();
const bool has_data_partition = Common::Contains(types, PARTITION_DATA);
if (!m_is_datel && !has_data_partition)
AddProblem(Severity::High, Common::GetStringT("The data partition is missing."));
const bool has_channel_partition =
std::find(types.cbegin(), types.cend(), PARTITION_CHANNEL) != types.cend();
const bool has_channel_partition = Common::Contains(types, PARTITION_CHANNEL);
if (ShouldHaveChannelPartition() && !has_channel_partition)
AddProblem(Severity::Medium, Common::GetStringT("The channel partition is missing."));
const bool has_install_partition =
std::find(types.cbegin(), types.cend(), PARTITION_INSTALL) != types.cend();
const bool has_install_partition = Common::Contains(types, PARTITION_INSTALL);
if (ShouldHaveInstallPartition() && !has_install_partition)
AddProblem(Severity::High, Common::GetStringT("The install partition is missing."));