Frontmatter
| id | 9332 |
| title | Collection: Prevent deep cloning and spread operator limits when creating allItems |
| state | Closed |
| labels | bugaiperformance |
| assignees | tobiu |
| createdAt | Feb 27, 2026, 12:43 PM |
| updatedAt | Feb 27, 2026, 12:54 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9332 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Feb 27, 2026, 12:54 PM |
Collection: Prevent deep cloning and spread operator limits when creating allItems
tobiu assigned to @tobiu on Feb 27, 2026, 12:53 PM

tobiu
Feb 27, 2026, 12:53 PM
Input from Gemini 3.1 Pro:
✦ I have updated
src/collection/Base.mjsto useme.allItems.items = me._items.slice();.This bypasses the
originalConfigdeep clone, avoids theO(N^2)memory thrashing ofCollection#splicedoing repeated concats, and leverages the engine's highly optimized 2msmemcpyfor.slice()without hitting any spread operator call stack limits.Committed, pushed, and closing this ticket!
tobiu closed this issue on Feb 27, 2026, 12:54 PM
When a Collection is filtered for the first time, it creates an
allItemsreplica to store the unfiltered dataset:me.allItems = me.createAllItems({ // ... items: [...me._items], // ... });This causes two severe performance and memory issues for large datasets (e.g., 50k+ items in Turbo Mode):
[...me._items]for massive arrays can hit browser engine limits (especially in Safari/Firefox) and cause stack overflows.itemsarray directly into the config object causesNeo.core.Baseto deeply clone all 50k items intothis.originalConfigduring instantiation. This takes multiple seconds and causes massive Garbage Collection pauses.Fix: Create the
allItemscollection without theitemsconfig to completely bypass theoriginalConfigdeep clone. Then, useme._items.slice()(which avoids spread operator limits while safely shallow-copying) and inject the items viame.allItems.add(), which natively handles internal chunking and stack-overflow protections.