Frontmatter
| id | 9336 |
| title | Performance: Optimize core utilities in Neo.mjs (cloneMap, camel, loops) |
| state | Closed |
| labels | enhancementaiperformancecore |
| assignees | tobiu |
| createdAt | Feb 27, 2026, 6:44 PM |
| updatedAt | Feb 27, 2026, 6:45 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9336 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Feb 27, 2026, 6:45 PM |
Performance: Optimize core utilities in Neo.mjs (cloneMap, camel, loops)
tobiu assigned to @tobiu on Feb 27, 2026, 6:44 PM

tobiu
Feb 27, 2026, 6:45 PM
Input from Gemini 3.1 Pro:
✦ Resolved in the linked commit.
- Replaced
forEachloops withfor...ofandfor...inincloneMap.Object,assignDefaults, andapplyFromNs.- Added an early return fast-path to
camel().- Changed
typeDetectorarrow functions to standard methods for better V8 engine optimization.
tobiu closed this issue on Feb 27, 2026, 6:45 PM
Problem
Several utility methods in
src/Neo.mjsthat are part of extremely hot paths (called thousands of times during initialization and config parsing) were using slightly unoptimized patterns. These included.forEachcallbacks, unnecessary regex executions for strings without dashes, and arrow functions in type detection maps.Solution
Implemented a series of micro-optimizations in
src/Neo.mjs:cloneMap.Object: ReplacedReflect.ownKeys(obj).forEach(...)with afor...ofloop to eliminate closure execution overhead while safely maintaining non-enumerable symbol cloning.camel(value): Added anif (!value.includes('-')) return value;fast-path to bypass the regex engine for pre-camel-cased or normal strings.assignDefaults&applyFromNs: ReplacedObject.entries().forEach(...)withfor...inloops, avoiding array allocation and closure overheads.typeDetector: Converted arrow functions to standard method definitions to help V8 optimize the functions without lexicalthisbinding overhead.