aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/projectstore/projectstore.cpp11
1 files 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<void(CbObjectView)>&& Hand
std::span<OplogEntryAddress> EntrySpan;
if (EntryPaging != nullptr)
{
- int32_t Indices[2] = {EntryPaging->Start, EntryPaging->Start + EntryPaging->Count};
- for (int32_t& Index : Indices)
- {
- Index = std::max<int32_t>(0, Index);
- Index = std::min<int32_t>(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
{