Frontmatter
| id | 9335 |
| title | Performance: Optimize array cloning in Neo.clone to use slice and map directly |
| state | Closed |
| labels | enhancementaiperformancecore |
| assignees | tobiu |
| createdAt | Feb 27, 2026, 6:24 PM |
| updatedAt | Feb 27, 2026, 6:27 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9335 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Feb 27, 2026, 6:27 PM |
Performance: Optimize array cloning in Neo.clone to use slice and map directly
tobiu assigned to @tobiu on Feb 27, 2026, 6:26 PM

tobiu
Feb 27, 2026, 6:26 PM
Input from Gemini 3.1 Pro:
✦ Resolved in the linked commit.
- Refactored
cloneMap.Arrayto utilize nativeslice()andmap()directly, removing the overhead of spreading via[...].- Simple change but ensures best possible V8 optimization for large datasets propagating through component configs.
tobiu closed this issue on Feb 27, 2026, 6:27 PM
Problem
The
Neo.cloneMap.Arraymethod used the ES6 spread operator ([...obj]and[...obj.map(...)]) to clone arrays. For a framework hot path called thousands of times during config reactivity and component initialization, the spread operator introduces unnecessary overhead by instantiating intermediate Iterator objects, which gets significantly slower compared to native methods for very large arrays.Solution
Refactored
cloneMap.Arrayinsrc/Neo.mjsto useobj.slice()for shallow clones andobj.map(...)directly for deep clones. This avoids the iterator overhead, resulting in roughly 2x faster shallow array cloning inside V8. This micro-optimization yields meaningful cumulative performance gains across the entire application lifecycle.