Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of inlines parsing of large content #107

Closed
nfejzic opened this issue Sep 24, 2023 · 0 comments · Fixed by #112
Closed

Improve performance of inlines parsing of large content #107

nfejzic opened this issue Sep 24, 2023 · 0 comments · Fixed by #112
Assignees

Comments

@nfejzic
Copy link
Collaborator

nfejzic commented Sep 24, 2023

When constructing TokenResolver we consume all tokens lexed by inlines lexer into a single Vec. This causes a very large memory allocation when parsing inlines in large content.

pub(crate) fn new(iter: TokenIterator<'token>) -> Self {
let mut new = Self {
curr_scope: 0,
interrupted: Vec::default(),
tokens: iter.map(RawToken::new).collect(),
};
new.resolve();
new
}

This should not happen very often (we're speaking of paragraph with hundreds of lines), but should be solved regardless.

One possible solution for this problem is to use tape-like data structure. The idea is, instead of directly using a vector of all tokens, use something like VecDeque and consume only those tokens that are necessary in order to resolve the first next token that should be returned by the TokenIterator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants