]> git.lizzy.rs Git - rust.git/commit
feat: make hightlighting linear
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 27 Nov 2021 17:50:07 +0000 (20:50 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 5 Dec 2021 12:32:39 +0000 (15:32 +0300)
commitc603b9043fd530c11d3001eb62b1315c5aa1afe0
tree776f0196c5fb5eaff1b9ad2e9bf5cea0f5b89d8f
parentb519a179b456c24dc8bcb675c2af6c0fd0733c29
feat: make hightlighting linear

In https://youtu.be/qvIZZf5dmTE, we've noticed that AstIdMap does a
linear lookup when going from SyntaxNode to Id. This leads to
accidentally quadratic overall performance. Replace linear lookup with a
O(1) hashmap lookup.

Future work: don't duplicate `SyntaxNodePtr` in `AstIdMap` and switch to
"call site dependency injection" style storage (eg, store a
`HashSet<ErasedFileAstId>`).

See the explanation of the work here on YouTube
https://youtu.be/wvEgymUm7cY :-)
crates/hir_expand/src/ast_id_map.rs