Summary
In events.ts, both eventBuffers and globalEventBuffer are pruned via buffer.splice(0, buffer.length - BUFFER_SIZE). splice() at index 0 shifts all remaining elements, which is O(n). With BUFFER_SIZE = 50, this happens on every event after the buffer fills.
Files Affected
src/events.ts (lines 119, 131, 282)
Suggested Fix
Use a circular buffer implementation (fixed-size array with head/tail indices) for O(1) operations.
Summary
In
events.ts, botheventBuffersandglobalEventBufferare pruned viabuffer.splice(0, buffer.length - BUFFER_SIZE).splice()at index 0 shifts all remaining elements, which is O(n). WithBUFFER_SIZE = 50, this happens on every event after the buffer fills.Files Affected
src/events.ts(lines 119, 131, 282)Suggested Fix
Use a circular buffer implementation (fixed-size array with head/tail indices) for O(1) operations.