aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/parsing/parser_impl.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-20 19:02:03 +0000
committerAleksey Kladov <[email protected]>2019-02-20 19:02:03 +0000
commitd2bce118ae72ee5cf96b8c6ac687914cb842363c (patch)
tree21e35f7d44add69cb3bc3d4af09e0bdd01dac0a9 /crates/ra_syntax/src/parsing/parser_impl.rs
parent0c81b9deeed81bfb2cf8142af9d748317d5d71a1 (diff)
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 #
Diffstat (limited to 'crates/ra_syntax/src/parsing/parser_impl.rs')
-rw-r--r--crates/ra_syntax/src/parsing/parser_impl.rs10
1 files changed, 5 insertions, 5 deletions
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: TreeSink>(
54) -> S::Tree { 54) -> S::Tree {
55 let mut events = { 55 let mut events = {
56 let input = input::ParserInput::new(text, tokens); 56 let input = input::ParserInput::new(text, tokens);
57 let parser_impl = ParserImpl::new(input); 57 let parser_impl = ParserImpl::new(&input);
58 let mut parser_api = Parser(parser_impl); 58 let mut parser_api = Parser(parser_impl);
59 parser(&mut parser_api); 59 parser(&mut parser_api);
60 parser_api.0.into_events() 60 parser_api.0.into_events()
@@ -65,15 +65,15 @@ pub(super) fn parse_with<S: TreeSink>(
65/// Implementation details of `Parser`, extracted 65/// Implementation details of `Parser`, extracted
66/// to a separate struct in order not to pollute 66/// to a separate struct in order not to pollute
67/// the public API of the `Parser`. 67/// the public API of the `Parser`.
68pub(super) struct ParserImpl<S> { 68pub(super) struct ParserImpl<'a> {
69 token_source: S, 69 token_source: &'a dyn TokenSource,
70 pos: InputPosition, 70 pos: InputPosition,
71 events: Vec<Event>, 71 events: Vec<Event>,
72 steps: Cell<u32>, 72 steps: Cell<u32>,
73} 73}
74 74
75impl<S: TokenSource> ParserImpl<S> { 75impl<'a> ParserImpl<'a> {
76 fn new(token_source: S) -> ParserImpl<S> { 76 fn new(token_source: &'a dyn TokenSource) -> ParserImpl<'a> {
77 ParserImpl { 77 ParserImpl {
78 token_source, 78 token_source,
79 pos: InputPosition::new(), 79 pos: InputPosition::new(),