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

Fix implementation of Lexer.detectable? #1425

Merged
merged 1 commit into from Feb 6, 2020

Conversation

ashmaroli
Copy link
Contributor

This fixes the existing memoization implemented in Lexer.detectable?.
Memoizing with ||= is negated when the computed result equals false. Instead, check if the singleton instance variable is defined and if so, return its value. Otherwise, proceed to compute and store result in the instance variable.

An additional change is replacing methods(false) with singleton_methods(false). For a singleton class, the two calls are equivalent and using the latter expresses intent better.

@pyrmont pyrmont self-assigned this Feb 5, 2020
@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Feb 5, 2020
@pyrmont pyrmont merged commit 6acbd5f into rouge-ruby:master Feb 6, 2020
@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Feb 6, 2020
@pyrmont
Copy link
Contributor

pyrmont commented Feb 6, 2020

Thanks @ashmaroli!

@jneen
Copy link
Member

jneen commented Feb 6, 2020

Good catch, thanks @ashmaroli!

@ashmaroli ashmaroli deleted the lexer-detectable-patch branch February 6, 2020 03:49
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