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
A Cop to detect wasteful initializations #71
Comments
Hi, @ashmaroli! The performance cops have recently been moved to their own repository. Please help move your issue over there. Thank you! 🙇 |
@Drenmi Will you be able to transfer this issue using the GitHub UI? |
Good suggestion @ashmaroli! That's a neat feature which I was not aware of. 🙂 |
You're welcome, Ted. 🙂 |
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
I frequently encounter non-memoized method definitions that involve generation of a constant object that doesn't depend on the state of the Class / Module.
Example
Given that there's a class with following instance methods:
The Hash generated in
:fallback_data
and the intermediate array in:cross_over
are both going to remain the same in any given instance of the Class. Multiple calls to these methods are going to allocate those objects unnecessarily .Describe the solution you'd like
Flag such methods and recommend stashing the constant-value objects as "constants", or consider memoizing them as "singleton methods"
The text was updated successfully, but these errors were encountered: