-
-
Notifications
You must be signed in to change notification settings - Fork 810
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
Consistently Frozen Constants #530
Comments
Hi @avit, good points. Things are evolving, but with Ruby 2.2 here is my current understanding:
So, it might make sense now in Ransack master and upcoming releases, to optimize for Ruby 2.2+ and stop using frozen constants, and replace them with frozen strings or symbols. |
I wasn't really considering symbols yet. When it comes to frozen strings vs. symbols I think you're right, they are essentially the same performance-wise and GC-wise now. Also, GC shouldn't be a concern since these "constants" are a fixed list of items: as long as we're not symbolizing user input like rails params used to do. The other considerations for String/Symbol are:
Targeting Ruby 2.2 for optimization going forward makes sense but I think we should be careful if we start doing anything like For now, I propose just changing the Ransack::Constants arrays as |
(If you want me to pull the declared constants e.g. |
Sounds good 👍 On Tuesday, April 7, 2015, Andrew Vit notifications@github.com wrote:
|
Looking at Ransack::Constants, it looks like most strings are frozen for optimization but there are also arrays with unfrozen strings via
%w(s t r).freeze
. I suspect this is an oversight.Is there any benefit if the arrays themselves are frozen too? (Personally I do have a case for modifying the arrays e.g. #123.)
The text was updated successfully, but these errors were encountered: