mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-08 15:20:45 +01:00
Modernize std::none_of
with ranges
In JitRegCache.cpp, the lambda predicate were replaced by a pointer to member function because ranges algorithms are able to invoke those. In ConvertDialog.cpp, the `std::mem_fn` helper was removed because ranges algorithms are able to handle pointers to member functions as predicates. In BoundingBox.cpp, the lambda predicate was returning the bool element unchanged, so `std::identity` was a better fit.
This commit is contained in:
parent
140252ffc0
commit
2b0cd16c8c
@ -51,10 +51,9 @@ Java_org_dolphinemu_dolphinemu_features_cheats_model_GraphicsModGroup_getMods(JN
|
|||||||
for (GraphicsModConfig& mod : mod_group->GetMods())
|
for (GraphicsModConfig& mod : mod_group->GetMods())
|
||||||
{
|
{
|
||||||
// If no group matches the mod's features, or if the mod has no features, skip it
|
// If no group matches the mod's features, or if the mod has no features, skip it
|
||||||
if (std::none_of(mod.m_features.begin(), mod.m_features.end(),
|
if (std::ranges::none_of(mod.m_features, [&groups](const GraphicsModFeatureConfig& feature) {
|
||||||
[&groups](const GraphicsModFeatureConfig& feature) {
|
return groups.contains(feature.m_group);
|
||||||
return groups.contains(feature.m_group);
|
}))
|
||||||
}))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,6 @@ std::string UnescapeFileName(const std::string& filename)
|
|||||||
bool IsFileNameSafe(const std::string_view filename)
|
bool IsFileNameSafe(const std::string_view filename)
|
||||||
{
|
{
|
||||||
return !filename.empty() && !std::ranges::all_of(filename, [](char c) { return c == '.'; }) &&
|
return !filename.empty() && !std::ranges::all_of(filename, [](char c) { return c == '.'; }) &&
|
||||||
std::none_of(filename.begin(), filename.end(), IsIllegalCharacter);
|
std::ranges::none_of(filename, IsIllegalCharacter);
|
||||||
}
|
}
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
@ -369,10 +369,8 @@ RCForkGuard RegCache::Fork()
|
|||||||
|
|
||||||
void RegCache::Discard(BitSet32 pregs)
|
void RegCache::Discard(BitSet32 pregs)
|
||||||
{
|
{
|
||||||
ASSERT_MSG(
|
ASSERT_MSG(DYNA_REC, std::ranges::none_of(m_xregs, &X64CachedReg::IsLocked),
|
||||||
DYNA_REC,
|
"Someone forgot to unlock a X64 reg");
|
||||||
std::none_of(m_xregs.begin(), m_xregs.end(), [](const auto& x) { return x.IsLocked(); }),
|
|
||||||
"Someone forgot to unlock a X64 reg");
|
|
||||||
|
|
||||||
for (preg_t i : pregs)
|
for (preg_t i : pregs)
|
||||||
{
|
{
|
||||||
@ -393,10 +391,8 @@ void RegCache::Discard(BitSet32 pregs)
|
|||||||
|
|
||||||
void RegCache::Flush(BitSet32 pregs, IgnoreDiscardedRegisters ignore_discarded_registers)
|
void RegCache::Flush(BitSet32 pregs, IgnoreDiscardedRegisters ignore_discarded_registers)
|
||||||
{
|
{
|
||||||
ASSERT_MSG(
|
ASSERT_MSG(DYNA_REC, std::ranges::none_of(m_xregs, &X64CachedReg::IsLocked),
|
||||||
DYNA_REC,
|
"Someone forgot to unlock a X64 reg");
|
||||||
std::none_of(m_xregs.begin(), m_xregs.end(), [](const auto& x) { return x.IsLocked(); }),
|
|
||||||
"Someone forgot to unlock a X64 reg");
|
|
||||||
|
|
||||||
for (preg_t i : pregs)
|
for (preg_t i : pregs)
|
||||||
{
|
{
|
||||||
@ -459,9 +455,8 @@ void RegCache::Commit()
|
|||||||
|
|
||||||
bool RegCache::IsAllUnlocked() const
|
bool RegCache::IsAllUnlocked() const
|
||||||
{
|
{
|
||||||
return std::none_of(m_regs.begin(), m_regs.end(), [](const auto& r) { return r.IsLocked(); }) &&
|
return std::ranges::none_of(m_regs, &PPCCachedReg::IsLocked) &&
|
||||||
std::none_of(m_xregs.begin(), m_xregs.end(), [](const auto& x) { return x.IsLocked(); }) &&
|
std::ranges::none_of(m_xregs, &X64CachedReg::IsLocked) && !IsAnyConstraintActive();
|
||||||
!IsAnyConstraintActive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegCache::PreloadRegisters(BitSet32 to_preload)
|
void RegCache::PreloadRegisters(BitSet32 to_preload)
|
||||||
|
@ -138,10 +138,9 @@ void GraphicsModListWidget::RefreshModList()
|
|||||||
for (const GraphicsModConfig& mod : m_mod_group.GetMods())
|
for (const GraphicsModConfig& mod : m_mod_group.GetMods())
|
||||||
{
|
{
|
||||||
// If no group matches the mod's features, or if the mod has no features, skip it
|
// If no group matches the mod's features, or if the mod has no features, skip it
|
||||||
if (std::none_of(mod.m_features.begin(), mod.m_features.end(),
|
if (std::ranges::none_of(mod.m_features, [&groups](const GraphicsModFeatureConfig& feature) {
|
||||||
[&groups](const GraphicsModFeatureConfig& feature) {
|
return groups.contains(feature.m_group);
|
||||||
return groups.contains(feature.m_group);
|
}))
|
||||||
}))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -248,9 +248,8 @@ void ConvertDialog::OnFormatChanged()
|
|||||||
m_compression->setEnabled(m_compression->count() > 1);
|
m_compression->setEnabled(m_compression->count() > 1);
|
||||||
|
|
||||||
// Block scrubbing of RVZ containers and Datel discs
|
// Block scrubbing of RVZ containers and Datel discs
|
||||||
const bool scrubbing_allowed =
|
const bool scrubbing_allowed = format != DiscIO::BlobType::RVZ &&
|
||||||
format != DiscIO::BlobType::RVZ &&
|
std::ranges::none_of(m_files, &UICommon::GameFile::IsDatelDisc);
|
||||||
std::none_of(m_files.begin(), m_files.end(), std::mem_fn(&UICommon::GameFile::IsDatelDisc));
|
|
||||||
|
|
||||||
m_scrub->setEnabled(scrubbing_allowed);
|
m_scrub->setEnabled(scrubbing_allowed);
|
||||||
if (!scrubbing_allowed)
|
if (!scrubbing_allowed)
|
||||||
|
@ -305,9 +305,10 @@ bool HotkeySuppressions::IsSuppressedIgnoringModifiers(Device::Input* input,
|
|||||||
return i1 && i2 && (i1 == i2 || i1->IsChild(i2) || i2->IsChild(i1));
|
return i1 && i2 && (i1 == i2 || i1->IsChild(i2) || i2->IsChild(i1));
|
||||||
};
|
};
|
||||||
|
|
||||||
return std::any_of(it, it_end, [&](auto& s) {
|
return std::any_of(it, it_end, [&](const auto& s) {
|
||||||
return std::none_of(begin(ignore_modifiers), end(ignore_modifiers),
|
return std::ranges::none_of(ignore_modifiers, [&](const auto& m) {
|
||||||
[&](auto& m) { return is_same_modifier(m->GetInput(), s.first.second); });
|
return is_same_modifier(m->GetInput(), s.first.second);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ void BoundingBox::Flush()
|
|||||||
|
|
||||||
m_is_valid = false;
|
m_is_valid = false;
|
||||||
|
|
||||||
if (std::none_of(m_dirty.begin(), m_dirty.end(), [](bool dirty) { return dirty; }))
|
if (std::ranges::none_of(m_dirty, std::identity{}))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: Does this make any difference over just writing all the values?
|
// TODO: Does this make any difference over just writing all the values?
|
||||||
|
Loading…
Reference in New Issue
Block a user