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

refactor: Cache moo lexer instances #9697

Merged
merged 2 commits into from Apr 23, 2021

Conversation

zharinov
Copy link
Collaborator

Changes:

Don't create new object each time we need to parse something.

Context:

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added unit tests, or
  • No new tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@zharinov
Copy link
Collaborator Author

zharinov commented Apr 23, 2021

As far as parsing code is synchronous, there should not be problems

@zharinov zharinov requested a review from viceice April 23, 2021 08:25
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as node functions can't be called in parallel (no multithreading in node yet).

The only think happens is the call order depends on async handling, so we need to be sure lexer state is not shared between async functions.

Also some small suggestions.

Comment on lines 158 to 159
lexer.reset();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lexer.reset();

I think this is not needed. 🤔

@@ -67,5 +66,6 @@ export function extractPackageFile(content: string): PackageFile {
}
token = lexer.next();
}
lexer.reset();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lexer.reset();

({ type, offset, value }) => ({ type, offset, value } as Token)
);
lexer.reset();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lexer.reset();

@viceice viceice merged commit 5716077 into renovatebot:main Apr 23, 2021
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 25.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants