diff options
author | Xavier Noria <fxn@hashref.com> | 2014-06-07 13:30:03 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2014-06-07 13:30:03 +0200 |
commit | f84d081faf6812a947aebf3e67978f3d3bbb31f0 (patch) | |
tree | 5a3912492351f52620b2c199220994c08b73dc0f /actionpack | |
parent | f712f89961b64b61064d99d33dbbfd1903b189d4 (diff) | |
download | rails-f84d081faf6812a947aebf3e67978f3d3bbb31f0.tar.gz rails-f84d081faf6812a947aebf3e67978f3d3bbb31f0.tar.bz2 rails-f84d081faf6812a947aebf3e67978f3d3bbb31f0.zip |
adds some details to the rationale of converted_arrays [ci skip]
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/parameters/parameters_permit_test.rb | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 55954d0f37..c3c3e4c4f1 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -129,6 +129,10 @@ module ActionController # 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 diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb index 14518d5ebd..aa894ffa17 100644 --- a/actionpack/test/controller/parameters/parameters_permit_test.rb +++ b/actionpack/test/controller/parameters/parameters_permit_test.rb @@ -176,7 +176,7 @@ class ParametersPermitTest < ActiveSupport::TestCase 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, |