Skip to content

Performance: Optimize array cloning in Neo.clone to use slice and map directly #9335

@tobiu

Description

@tobiu

Problem

The Neo.cloneMap.Array method 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.Array in src/Neo.mjs to use obj.slice() for shallow clones and obj.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.

Metadata

Metadata

Assignees

Labels

aicoreCore framework functionalityenhancementNew feature or requestperformancePerformance improvements and optimizations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions