-
-
Notifications
You must be signed in to change notification settings - Fork 202
Performance: Optimize core utilities in Neo.mjs (cloneMap, camel, loops) #9336
Copy link
Copy link
Closed
Labels
aicoreCore framework functionalityCore framework functionalityenhancementNew feature or requestNew feature or requestperformancePerformance improvements and optimizationsPerformance improvements and optimizations
Description
Problem
Several utility methods in src/Neo.mjs that are part of extremely hot paths (called thousands of times during initialization and config parsing) were using slightly unoptimized patterns. These included .forEach callbacks, 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aicoreCore framework functionalityCore framework functionalityenhancementNew feature or requestNew feature or requestperformancePerformance improvements and optimizationsPerformance improvements and optimizations