v1.8.0 Performance Overhaul
What's Changed
- v1.8.0 Performance Overhaul by @BenBaryoPX in #81
Major refactor around loop optimizations and VM resource sharing.
Remove redundant iterations over the AST array. No more candidates (except for where it makes sense) - instead the logic is executed on the first iteration over the AST array.
Replace builtin iterations methods like [].filter and [].forEach with a for loop with an index iterator to remove the function creation overhead.
Replace !![].filter().length tests with [].some. The same for [].find => [].some if the value is used as a boolean.
Replace for-of loops with for loops with an index iterator to remove the array size calculation overhead.
Replace generateFlatAST with parseCode where there's no need for node enrichment.
Reorder test in if clauses to make the 'cheaper' tests first, reducing the cost of failing the tests early.
Add a flushing mechanism to the cache object. Can be used in expesive modules where a lot of costly cache is used.
Extract VM creation from evalInVm and allow modules to save, re-use, and share execution context. This removes the overhead of creating a VM on each execution, while also allows to finally run context code 1 time and use it for localized executions that require that context.
Full Changelog: v1.7.3...v1.8.0