From 41c04ded937ff6423d5549afd7f5e8de211a9e31 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sat, 28 Sep 2024 22:26:43 -0700 Subject: [PATCH] Modernize `std::lower_bound`/`upper_bound` with ranges and projections --- Source/Core/Common/MemArenaWin.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Core/Common/MemArenaWin.cpp b/Source/Core/Common/MemArenaWin.cpp index a991687d91..7907979775 100644 --- a/Source/Core/Common/MemArenaWin.cpp +++ b/Source/Core/Common/MemArenaWin.cpp @@ -220,9 +220,7 @@ WindowsMemoryRegion* MemArena::EnsureSplitRegionForMapping(void* start_address, } // find closest region that is <= the given address by using upper bound and decrementing - auto it = std::upper_bound( - regions.begin(), regions.end(), address, - [](u8* addr, const WindowsMemoryRegion& region) { return addr < region.m_start; }); + auto it = std::ranges::upper_bound(regions, address, {}, &WindowsMemoryRegion::m_start); if (it == regions.begin()) { // this should never happen, implies that the given address is before the start of the @@ -363,9 +361,7 @@ bool MemArena::JoinRegionsAfterUnmap(void* start_address, size_t size) } // there should be a mapping that matches the request exactly, find it - auto it = std::lower_bound( - regions.begin(), regions.end(), address, - [](const WindowsMemoryRegion& region, u8* addr) { return region.m_start < addr; }); + auto it = std::ranges::lower_bound(regions, address, {}, &WindowsMemoryRegion::m_start); if (it == regions.end() || it->m_start != address || it->m_size != size) { // didn't find it, we were given bogus input