Skip to content

How does changing the node without calling SKIP cause performance issues? #107

Closed Answered by ChristianMurphy
lubiah asked this question in Q&A
Discussion options

You must be logged in to vote

Welcome @lubiah 👋
The potential issue is within the plugin where the transformation is happening.

The visitor does a depth first traversal.
https://github.com/syntax-tree/unist-util-visit-parents#visitparentstree-test-visitor-reverse
https://en.m.wikipedia.org/wiki/Tree_traversal

Meaning if you modify the current node, that will effect the traversal of its children.

Some example of how this can cause bugs or performance problems (there are many more)

  1. Doing async replacement, the visitor is sync, if the children or node are modified async, the tree traversal will work on the old tree and will never see the new nodes or know the old node was removed.
  2. Modifying the node accidentally with a …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@lubiah
Comment options

@ChristianMurphy
Comment options

@lubiah
Comment options

Answer selected by lubiah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants