Permalink
Browse files

Avoid range object creation

  • Loading branch information...
1 parent 938243f commit d3f8765482133df14d355f1763d3df1c883d2689 @spastorino spastorino committed Nov 20, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 actionpack/lib/abstract_controller/rendering.rb
@@ -128,7 +128,7 @@ def view_assigns
hash = {}
variables = instance_variable_names
variables -= protected_instance_variables if respond_to?(:protected_instance_variables)
- variables.each { |name| hash[name.to_s[1..-1]] = instance_variable_get(name) }
+ variables.each { |name| hash[name.to_s[1, name.length]] = instance_variable_get(name) }
hash
end

3 comments on commit d3f8765

why? it's faster?

@stjhimy: the fewer objects you create, the less memory you need. This is a good optimization.

Thanks

Please sign in to comment.