Merge pull request #13093 from mitaclaw/ranges-modernization-4-projection

Ranges Algorithms Modernization - Projection
This commit is contained in:
JMC47
2025-03-23 15:56:13 -04:00
committed by GitHub
36 changed files with 128 additions and 176 deletions

View File

@ -165,10 +165,8 @@ std::vector<std::string> GlobalConflicts(std::string_view source)
// Sort the conflicts from largest to smallest string
// this way we can ensure smaller strings that are a substring
// of the larger string are able to be replaced appropriately
std::sort(global_result.begin(), global_result.end(),
[](const std::string& first, const std::string& second) {
return first.size() > second.size();
});
std::ranges::sort(global_result, std::ranges::greater{},
[](const std::string& s) { return s.size(); });
return global_result;
}

View File

@ -1663,11 +1663,8 @@ RcTcacheEntry TextureCacheBase::CreateTextureEntry(
if (!assets_data.empty())
{
const auto calculate_max_levels = [&]() {
const auto max_element = std::max_element(
assets_data.begin(), assets_data.end(), [](const auto& lhs, const auto& rhs) {
return lhs->m_texture.m_slices[0].m_levels.size() <
rhs->m_texture.m_slices[0].m_levels.size();
});
const auto max_element = std::ranges::max_element(
assets_data, {}, [](const auto& v) { return v->m_texture.m_slices[0].m_levels.size(); });
return (*max_element)->m_texture.m_slices[0].m_levels.size();
};
const u32 texLevels = no_mips ? 1 : (u32)calculate_max_levels();
@ -2024,8 +2021,7 @@ void TextureCacheBase::StitchXFBCopy(RcTcacheEntry& stitched_entry)
if (candidates.empty())
return;
std::sort(candidates.begin(), candidates.end(),
[](const TCacheEntry* a, const TCacheEntry* b) { return a->id < b->id; });
std::ranges::sort(candidates, {}, &TCacheEntry::id);
// We only upscale when necessary to preserve resolution. i.e. when there are upscaled partial
// copies to be stitched together.

View File

@ -221,9 +221,7 @@ void VideoBackendBase::ActivateBackend(const std::string& name)
g_video_backend = GetDefaultVideoBackend();
const auto& backends = GetAvailableBackends();
const auto iter = std::find_if(backends.begin(), backends.end(), [&name](const auto& backend) {
return name == backend->GetName();
});
const auto iter = std::ranges::find(backends, name, &VideoBackendBase::GetName);
if (iter == backends.end())
return;