rust-analyzer / rowan

Apache License 2.0
715 stars 61 forks source link

Optimize children iteration by reusing NodeData if possible #171

Closed milianw closed 1 month ago

milianw commented 1 month ago

The first patch here is a rebased and slightly adapted version of https://github.com/rust-analyzer/rowan/pull/119 (the adaption is the addition of missing forwards in api.rs). I believe that part should be reviewed in the existing pull request which hopefully could be updated by @theo-lw (feel free to take the patch here if it's to your likings).

The second patch in here is new - it's an additional optimization which allows us to further reduce the number of memory allocations required for rowan tree visitation in slint by another 50%. I.e. combined, the two patches go from 850k allocations down to 450k down to 230k, a total reduction by ~73%!