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

Introduce :detectable? singleton method for lexers #1149

Merged
merged 2 commits into from
Jun 2, 2019

Conversation

ashmaroli
Copy link
Contributor

Calling methods(false).include? :detect? frequently is a significant memory-drain as it generates short-lived arrays (of varying size per lexer) only to be immediately swept away by the GC.

Instead, cache the result of the expression in the lexer's singleton class on the first evaluation, and send the cached result on subsequent calls from the same lexer class.

Closes #1148

spec/lexers/abap_spec.rb Outdated Show resolved Hide resolved
spec/lexers/awk_spec.rb Outdated Show resolved Hide resolved
@pyrmont pyrmont added the author-action The PR has been reviewed but action by the author is needed label Jun 2, 2019
@pyrmont pyrmont merged commit 8800d7f into rouge-ruby:master Jun 2, 2019
@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Jun 2, 2019
@ashmaroli
Copy link
Contributor Author

Thank you @pyrmont 😃

@ashmaroli ashmaroli deleted the detectable-lexers branch June 2, 2019 17:41
@pyrmont
Copy link
Contributor

pyrmont commented Jun 2, 2019

Good addition, I think :)

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 this pull request may close these issues.

Allocations in Guessers::Source
2 participants