rust-analyzer / rowan

Apache License 2.0
677 stars 57 forks source link

Investigate non-natural tree embeddings #124

Open matklad opened 2 years ago

matklad commented 2 years ago

Today, Rowan's logical tree shape is identical to the physical shape of the tree data structure. That's natural (you might even wonder what is the other option), but is not necessary optimal. In particular, natural tree sometimes have very wide nodes with hundreds of children. Traversing or modifying such nodes sometimes is O(len(children)), which might give poor worst-case complexity.

An alternative is to make sure that the physical shape of the data structure is always a ballaned tree. For example, we can introduce a TRANSPARENT SyntaxKind, and represent long sequences as deep, balanced trees with TRANSPARENT internal nodes.