From 2d799cf5e0ffd414ce47d8b9478148f98b46028a Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 18 Jan 2021 18:40:06 +0100 Subject: shrink_to_fit `TokenMap`'s backing storage --- crates/mbe/src/syntax_bridge.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/mbe/src') 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 let global_offset = node.text_range().start(); let mut c = Convertor::new(node, global_offset); let subtree = c.go()?; + c.id_alloc.map.entries.shrink_to_fit(); Some((subtree, c.id_alloc.map)) } @@ -593,7 +594,8 @@ impl<'a> TtTreeSink<'a> { } } - fn finish(self) -> (Parse, TokenMap) { + fn finish(mut self) -> (Parse, TokenMap) { + self.token_map.entries.shrink_to_fit(); (self.inner.finish(), self.token_map) } } -- cgit v1.2.3