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

TokenStream use VecDeque instead of Vec #292

Closed
GreasySlug opened this issue Dec 14, 2022 · 1 comment · Fixed by #337
Closed

TokenStream use VecDeque instead of Vec #292

GreasySlug opened this issue Dec 14, 2022 · 1 comment · Fixed by #337

Comments

@GreasySlug
Copy link
Member

Currently the tokenStream uses Vec
This method has self.lpop() and self.skip

    #[inline]
    fn skip(&mut self) {
        self.tokens.remove(0);
    }

    #[inline]
    fn lpop(&mut self) -> Token {
        self.tokens.remove(0)
    }

This self.remove(0) calculation cost is O(n)
For short scripts, the computational cost is not a problem, but for scripts with more than 5k lines, the Parser starts to take a long time to process.

@mtshiba
Copy link
Member

mtshiba commented Dec 14, 2022

It would be more efficient to replace structures other than TokenStream that use Vec internally to perform remove(0) with VecDeque.

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

Successfully merging a pull request may close this issue.

2 participants