Skip to content
Browse files

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

…er than var.sub('@', '')
  • Loading branch information...
1 parent 2380c71 commit e99c89476741050e91f6908d007951c8d94c18fe @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
@@ -189,9 +189,9 @@ def _instance_variables
end
def _assigns
- _instance_variables.inject({}) do |hash, var|
- hash.merge(var.sub('@','').to_sym => instance_variable_get(var))
- end
+ Hash[_instance_variables.map do |var|
+ [var[1..-1].to_sym, instance_variable_get(var)]
+ end]
end
def _routes

0 comments on commit e99c894

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