Skip to content

Commit

Permalink
Remove extra loop in view_assigns (#38766)
Browse files Browse the repository at this point in the history
* Remove extra loop in view_assigns

* Use slice instead of range
  • Loading branch information
vinistock committed Mar 19, 2020
1 parent 033a738 commit f6bf170
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions actionpack/lib/abstract_controller/rendering.rb
Expand Up @@ -64,12 +64,12 @@ def rendered_format
# You can overwrite this configuration per controller.
def view_assigns
protected_vars = _protected_ivars
variables = instance_variables

variables.reject! { |s| protected_vars.include? s }
variables.each_with_object({}) { |name, hash|
hash[name.slice(1, name.length)] = instance_variable_get(name)
}
instance_variables.each_with_object({}) do |name, hash|
unless protected_vars.include?(name)
hash[name.slice(1, name.length)] = instance_variable_get(name)
end
end
end

private
Expand Down

0 comments on commit f6bf170

Please sign in to comment.