From 93bd1be0c6dc35fc270755eb498382e4a58fcb52 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 12 Sep 2024 15:26:06 +0200 Subject: Forgot there was a std::clamp --- src/zenserver/projectstore/projectstore.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp index b58f490e2..0e1fb2e9a 100644 --- a/src/zenserver/projectstore/projectstore.cpp +++ b/src/zenserver/projectstore/projectstore.cpp @@ -2065,13 +2065,10 @@ ProjectStore::Oplog::IterateOplogLocked(std::function&& Hand std::span EntrySpan; if (EntryPaging != nullptr) { - int32_t Indices[2] = {EntryPaging->Start, EntryPaging->Start + EntryPaging->Count}; - for (int32_t& Index : Indices) - { - Index = std::max(0, Index); - Index = std::min(Index, int32_t(Entries.size())); - } - EntrySpan = decltype(EntrySpan)(Entries.begin() + Indices[0], Indices[1] - Indices[0]); + int32_t Size = int32_t(Entries.size()); + int32_t Start = std::clamp(EntryPaging->Start, 0, Size); + int32_t End = std::clamp(EntryPaging->Start + EntryPaging->Count, 0, Size); + EntrySpan = decltype(EntrySpan)(Entries.begin() + Start, End - Start); } else { -- cgit v1.2.3