Skip to content

Commit

Permalink
adds some details to the rationale of converted_arrays [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Jun 7, 2014
1 parent f712f89 commit f84d081
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions actionpack/lib/action_controller/metal/strong_parameters.rb
Expand Up @@ -129,6 +129,10 @@ def initialize(attributes = nil)
# Attribute that keeps track of converted arrays, if any, to avoid double
# looping in the common use case permit + mass-assignment. Defined in a
# method to instantiate it only if needed.
#
# Testing membership still loops, but it's going to be faster than our own
# loop that converts values. Also, we are not going to build a new array
# object per fetch.
def converted_arrays
@converted_arrays ||= Set.new
end
Expand Down
Expand Up @@ -176,7 +176,7 @@ def assert_filtered_out(params, key)
end

# Strong params has an internal cache to avoid duplicated loops in the most
# common usage pattern. See the docs of the method `coverted_array`.
# common usage pattern. See the docs of the method `converted_arrays`.
#
# This test checks that if we push a hash to an array (in-place modification)
# the cache does not get fooled, the hash is still wrapped as strong params,
Expand Down

0 comments on commit f84d081

Please sign in to comment.