Skip to content
Browse files

PERF: Hash[] + map is faster than this silly inject, and var[1..-1] i…

…s faster than var.sub('@', '')
  • Loading branch information...
1 parent f656796 commit c28bebef13b8a0e497fc7bbb83f542e9400e07e5 @spastorino spastorino committed Oct 3, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 actionpack/lib/action_view/test_case.rb
View
6 actionpack/lib/action_view/test_case.rb
@@ -200,9 +200,9 @@ def _user_defined_ivars
# 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

0 comments on commit c28bebe

Please sign in to comment.
Something went wrong with that request. Please try again.