Skip to content
Browse files

adds some details to the rationale of converted_arrays [ci skip]

  • Loading branch information...
1 parent f712f89 commit f84d081faf6812a947aebf3e67978f3d3bbb31f0 @fxn fxn committed Jun 7, 2014
View
4 actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -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
View
2 actionpack/test/controller/parameters/parameters_permit_test.rb
@@ -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,

0 comments on commit f84d081

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