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

Avoid creating a new array on every Lexer.all call #1140

Merged
merged 2 commits into from
Jun 3, 2019

Conversation

ashmaroli
Copy link
Contributor

  • Memoizing Lexer.all since every call to registry.values.uniq will return a new array for the same contents
    (same #hash value but different #object_id values)

Note: This is under the assumption that the Lexer.all list shouldn't change for the lifetime and all user-defined lexers have been registered by this point.

@jneen
Copy link
Member

jneen commented May 31, 2019

I am happy with this as long as we invalidate the cache when registering new lexers. Users often define lexers for custom languages, and we want those to show up in the registry and be accessible for guessing.

@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed maintainer-action The PR has been reviewed but action by a maintainer is required and removed author-action The PR has been reviewed but action by the author is needed labels May 31, 2019
@pyrmont pyrmont merged commit 88a4009 into rouge-ruby:master Jun 3, 2019
@pyrmont pyrmont removed the maintainer-action The PR has been reviewed but action by a maintainer is required label Jun 3, 2019
@ashmaroli ashmaroli deleted the all-lexers-list branch June 19, 2019 05:25
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.

None yet

3 participants