Skip to content

Commit 1c01367

Browse files
roboclaw-botVACInc
andcommitted
perf: avoid copying complete companion pages
Worked on by: - @VACInc Co-authored-by: VACInc <[email protected]>
1 parent 1fd7091 commit 1c01367

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/gateway/session-companion-context.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ async function readSessionCompanionContext(params: {
186186
const pageIsPartial = page.newestContiguousEventCount !== page.scannedMessages;
187187
// Sparse bounded pages may include older rows beyond an oversized gap.
188188
// Only the contiguous newest suffix is authoritative companion context.
189-
const pageEvents = page.events.slice(page.events.length - page.newestContiguousEventCount);
189+
const pageEvents =
190+
page.newestContiguousEventCount === page.events.length
191+
? page.events
192+
: page.events.slice(page.events.length - page.newestContiguousEventCount);
190193
rawBytes += page.serializedBytes;
191194
scannedMessages += page.scannedMessages;
192195
offset += page.scannedMessages;

0 commit comments

Comments
 (0)