diff options
author | Jonas Schievink <[email protected]> | 2021-01-18 17:40:06 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-01-18 17:40:06 +0000 |
commit | 2d799cf5e0ffd414ce47d8b9478148f98b46028a (patch) | |
tree | cd9ef812cb400cdba2ea691e07e3cfb8a6d55944 /crates | |
parent | 9daba961f236750c3a5d831c9775606271b37eff (diff) |
shrink_to_fit `TokenMap`'s backing storage
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_expand/src/hygiene.rs | 2 | ||||
-rw-r--r-- | crates/mbe/src/syntax_bridge.rs | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs index 8db581b77..c8ea81210 100644 --- a/crates/hir_expand/src/hygiene.rs +++ b/crates/hir_expand/src/hygiene.rs | |||
@@ -76,6 +76,8 @@ pub struct HygieneFrame { | |||
76 | 76 | ||
77 | impl HygieneFrames { | 77 | impl HygieneFrames { |
78 | fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Self { | 78 | fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Self { |
79 | // Note that this intentionally avoids the `hygiene_frame` query to avoid blowing up memory | ||
80 | // usage. The query is only helpful for nested `HygieneFrame`s as it avoids redundant work. | ||
79 | HygieneFrames(Arc::new(HygieneFrame::new(db, file_id))) | 81 | HygieneFrames(Arc::new(HygieneFrame::new(db, file_id))) |
80 | } | 82 | } |
81 | 83 | ||
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index e648519f9..2a41d8167 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs | |||
@@ -51,6 +51,7 @@ pub fn syntax_node_to_token_tree(node: &SyntaxNode) -> Option<(tt::Subtree, Toke | |||
51 | let global_offset = node.text_range().start(); | 51 | let global_offset = node.text_range().start(); |
52 | let mut c = Convertor::new(node, global_offset); | 52 | let mut c = Convertor::new(node, global_offset); |
53 | let subtree = c.go()?; | 53 | let subtree = c.go()?; |
54 | c.id_alloc.map.entries.shrink_to_fit(); | ||
54 | Some((subtree, c.id_alloc.map)) | 55 | Some((subtree, c.id_alloc.map)) |
55 | } | 56 | } |
56 | 57 | ||
@@ -593,7 +594,8 @@ impl<'a> TtTreeSink<'a> { | |||
593 | } | 594 | } |
594 | } | 595 | } |
595 | 596 | ||
596 | fn finish(self) -> (Parse<SyntaxNode>, TokenMap) { | 597 | fn finish(mut self) -> (Parse<SyntaxNode>, TokenMap) { |
598 | self.token_map.entries.shrink_to_fit(); | ||
597 | (self.inner.finish(), self.token_map) | 599 | (self.inner.finish(), self.token_map) |
598 | } | 600 | } |
599 | } | 601 | } |