1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

PERF: Hash[] + map is faster than this silly inject, and var[1..-1] is faster than var.sub('@', '')

This commit is contained in:
Santiago Pastorino 2010-10-03 13:34:34 -02:00
parent f656796d05
commit c28bebef13

View file

@ -200,9 +200,9 @@ module ActionView
# rendered. This is generally intended for internal use and extension
# frameworks.
def view_assigns
_user_defined_ivars.inject({}) do |hash, var|
hash.merge(var.sub('@','').to_sym => instance_variable_get(var))
end
Hash[_user_defined_ivars.map do |var|
[var[1..-1].to_sym, instance_variable_get(var)]
end]
end
def _assigns