Permalink
Browse files

Perf: refactor _assign method to avoid inject and defining unneeded l…

…ocal var.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
miloops authored and spastorino committed Sep 22, 2010
1 parent 8105bc0 commit e66c1cee86aba1c81152f3d0872313e65cec85a9
Showing with 1 addition and 5 deletions.
  1. +1 −5 actionpack/lib/action_view/test_case.rb
@@ -189,11 +189,7 @@ def _instance_variables
end
def _assigns
- _instance_variables.inject({}) do |hash, var|
- name = var[1..-1].to_sym
- hash[name] = instance_variable_get(var)
- hash
- end
+ _instance_variables.map { |var| [ var[1..-1].to_sym, instance_variable_get(var)] }
end
def _routes

4 comments on commit e66c1ce

@dchelimsky

This comment has been minimized.

Show comment Hide comment
@dchelimsky

dchelimsky Oct 2, 2010

Contributor

This commit changes the return value of _assigns from a Hash to an Array, which breaks rspec-rails and any other extensions that might depend on this.

Contributor

dchelimsky replied Oct 2, 2010

This commit changes the return value of _assigns from a Hash to an Array, which breaks rspec-rails and any other extensions that might depend on this.

@spastorino

This comment has been minimized.

Show comment Hide comment
@spastorino

spastorino Oct 2, 2010

Member

Yes that's true, can you fix it and add tests.

Member

spastorino replied Oct 2, 2010

Yes that's true, can you fix it and add tests.

@dchelimsky

This comment has been minimized.

Show comment Hide comment
@dchelimsky

dchelimsky Oct 2, 2010

Contributor

Already working w/ José on this one. He already reverted this commit, and I just submitted a patch to add test cases and rename _assigns to view_assigns to make it a) feel more public and b) align with controllers:

https://rails.lighthouseapp.com/projects/8994/tickets/5751
http://github.com/dchelimsky/rails/commit/14bf17deb8fc8235b3a4f989d12ed9f1aa4d0abb

Cheers,
David

Contributor

dchelimsky replied Oct 2, 2010

Already working w/ José on this one. He already reverted this commit, and I just submitted a patch to add test cases and rename _assigns to view_assigns to make it a) feel more public and b) align with controllers:

https://rails.lighthouseapp.com/projects/8994/tickets/5751
http://github.com/dchelimsky/rails/commit/14bf17deb8fc8235b3a4f989d12ed9f1aa4d0abb

Cheers,
David

@spastorino

This comment has been minimized.

Show comment Hide comment
@spastorino

spastorino Oct 2, 2010

Member

Cool David thank you

Member

spastorino replied Oct 2, 2010

Cool David thank you

Please sign in to comment.