diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-13 13:04:45 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-13 13:04:45 +0000 |
commit | fe4a94fff379e69acf31bf4c8b0d2490107a2dae (patch) | |
tree | 65f614b2c839379c294f4ea08564d135f5b7ad4c /crates/mbe/src/expander.rs | |
parent | 88f78bdb9b64e0ba4ca5924599e42a524f5c3b64 (diff) | |
parent | 9117148f42371108f49de84ff765da987dcb5917 (diff) |
Merge #7994
7994: Speed up mbe matching in heavy recursive cases r=edwin0cheng a=edwin0cheng
In some cases (e.g. #4186), mbe matching is very slow due to a lot of copy and allocation for bindings, this PR try to solve this problem by introduce a semi "link-list" approach for bindings building.
I used this [test case](https://github.com/weiznich/minimal_example_for_rust_81262) (for `features(32-column-tables)`) to run following command to benchmark:
```
time rust-analyzer analysis-stats --load-output-dirs ./
```
Before this PR : 2 mins
After this PR: 3 seconds.
However, for 64-column-tables cases, we still need 4 mins to complete.
I will try to investigate in the following weeks.
bors r+
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/mbe/src/expander.rs')
-rw-r--r-- | crates/mbe/src/expander.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/mbe/src/expander.rs b/crates/mbe/src/expander.rs index 2efff8f52..3197c834c 100644 --- a/crates/mbe/src/expander.rs +++ b/crates/mbe/src/expander.rs | |||
@@ -5,7 +5,7 @@ | |||
5 | mod matcher; | 5 | mod matcher; |
6 | mod transcriber; | 6 | mod transcriber; |
7 | 7 | ||
8 | use smallvec::SmallVec; | 8 | use rustc_hash::FxHashMap; |
9 | use syntax::SmolStr; | 9 | use syntax::SmolStr; |
10 | 10 | ||
11 | use crate::{ExpandError, ExpandResult}; | 11 | use crate::{ExpandError, ExpandResult}; |
@@ -96,7 +96,7 @@ pub(crate) fn expand_rules( | |||
96 | /// many is not a plain `usize`, but an `&[usize]`. | 96 | /// many is not a plain `usize`, but an `&[usize]`. |
97 | #[derive(Debug, Default, Clone, PartialEq, Eq)] | 97 | #[derive(Debug, Default, Clone, PartialEq, Eq)] |
98 | struct Bindings { | 98 | struct Bindings { |
99 | inner: SmallVec<[(SmolStr, Binding); 4]>, | 99 | inner: FxHashMap<SmolStr, Binding>, |
100 | } | 100 | } |
101 | 101 | ||
102 | #[derive(Debug, Clone, PartialEq, Eq)] | 102 | #[derive(Debug, Clone, PartialEq, Eq)] |