Fast Remove
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
As part of the future performance improvements, working on improving the `#remove()` method's performance might be a good start.
On remove, the following happens today:
1. Source file text is changed to not include the node's text.
2. Source file text is reparsed.
3. Wrapped nodes are updated with new compiler nodes.
A better solution, but a bit more complicated would be:
1. Source file text is changed to not include the node's text.
2. Existing AST is manipulated to remove the removed node (ex. update `#statements` and `#_children` when removing a statement)
3. Go up the parents, and down the following nodes to change any `pos` and `end` properties. Also, remove stuff like symbols and such (need to investigate more)
4. Update the source file text.
5. Forget the removed node.
Not having to reparse and fill the wrapped nodes with new nodes should improve the performance big time. This change will have no effect on the public API.
Note: The tests for these should do a deep search of the final AST to ensure the previous compiler node isn't remaining inside the AST somewhere and that no symbols exist hidden within the `AST`. I'll need to edit private and internal data in the nodes to do this.
When adding this, be sure to add some metrics to the project specifically for this scenario (need line graph showing performance over every commit... do worst case and best case on some generated data).
Contributor guide
Assessment
This issue has not been assessed yet.