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

Disable Performance/OpenStruct for Rubies >= 2.1 #361

Open
mikegee opened this issue Jun 12, 2023 · 0 comments
Open

Disable Performance/OpenStruct for Rubies >= 2.1 #361

mikegee opened this issue Jun 12, 2023 · 0 comments

Comments

@mikegee
Copy link

mikegee commented Jun 12, 2023

Is your feature request related to a problem? Please describe.

rubocop-performance told me to avoid instantiating OpenStructs because it invalidates the Ruby global method cache. But I recall Ruby changed the way it cached methods a while ago.

I am fairly confident that the claim:

Instantiation of an OpenStruct invalidates Ruby global method cache

has been untrue since Ruby 2.1.

references:

That change was merged in 2013 and almost certainly released with Ruby 2.1 in December 2013.

See also this tweet from Nate Berkopec:

TIL openstruct does not invalidate the global method cache in Ruby 2.1+ #rubyconf

https://twitter.com/nateberkopec/status/796743575392440320

Describe the solution you'd like

We can probably look at the TargetRubyVersion and only check the older Rubies.

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

No branches or pull requests

1 participant