From d2bce118ae72ee5cf96b8c6ac687914cb842363c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 Feb 2019 22:02:03 +0300 Subject: switch to dynamic dispatch for TokenSource Benchmarks show no difference. This is probably because we are bottlenecked on memory allocations, and we should fix that, but we are not optimizing for performance just yet. changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch token-source # Changes to be committed: # modified: crates/ra_syntax/src/parsing/parser_api.rs # modified: crates/ra_syntax/src/parsing/parser_impl.rs # --- crates/ra_syntax/src/parsing/parser_impl.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_syntax/src/parsing/parser_impl.rs') diff --git a/crates/ra_syntax/src/parsing/parser_impl.rs b/crates/ra_syntax/src/parsing/parser_impl.rs index c0d2b6ec1..96de32fc2 100644 --- a/crates/ra_syntax/src/parsing/parser_impl.rs +++ b/crates/ra_syntax/src/parsing/parser_impl.rs @@ -54,7 +54,7 @@ pub(super) fn parse_with( ) -> S::Tree { let mut events = { let input = input::ParserInput::new(text, tokens); - let parser_impl = ParserImpl::new(input); + let parser_impl = ParserImpl::new(&input); let mut parser_api = Parser(parser_impl); parser(&mut parser_api); parser_api.0.into_events() @@ -65,15 +65,15 @@ pub(super) fn parse_with( /// Implementation details of `Parser`, extracted /// to a separate struct in order not to pollute /// the public API of the `Parser`. -pub(super) struct ParserImpl { - token_source: S, +pub(super) struct ParserImpl<'a> { + token_source: &'a dyn TokenSource, pos: InputPosition, events: Vec, steps: Cell, } -impl ParserImpl { - fn new(token_source: S) -> ParserImpl { +impl<'a> ParserImpl<'a> { + fn new(token_source: &'a dyn TokenSource) -> ParserImpl<'a> { ParserImpl { token_source, pos: InputPosition::new(), -- cgit v1.2.3