mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
Three small wins on paths the projection runs every event arrival or every snapshot publish: 1. Cache `address` on Slot. Previously `removeIndexes(slot)` called `addressOf(slot.flow.value)` on every drop — for replaceables that's a fresh Address allocation every time. Now the address is computed once at slot construction and reused on removal. 2. Single-filter snapshot fast path. The deduped sorted union via TreeSet was unnecessary when there's only one per-filter set — that set is already sorted in the slot comparator's order. The common UI case (one filter per projection) now skips the TreeSet allocation + log-n inserts entirely. 3. Comparator singleton. `slotComparator()` was allocating a fresh Comparator lambda on every call (ctor + every snapshot). Replaced with a single `Comparator<Slot<*>>` cast at the use site — the comparator only reads sort keys that don't depend on the type parameter. Also trimmed a verbose comment block in `project()` (3 lines → 1). All 18 projection tests + 240 store + interner tests still pass. https://claude.ai/code/session_01Jny85MTu1ynKgFBgysfWu5