1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test
Xavier Noria 26dd9b26ab significant speedup of AC::Parameters#permit
The current implementation of AC::Parameters#permit builds permitted hashes and
then calls permit! on them.

This filtering is recursive, so we call permit! on terminal branches, but then
ascendants call permit! on themselves when the recursion goes up the stack,
which recurses all the way down again because permit! is recursive itself.
Repeat this for every parent node and you get some scary O-something going on
that I don't even want to compute.

Instead, since the whole point of the permit recursion is to build permitted
hashes along the way and at that point you know you've just come up with a
valid filtered version, you can already switch the toggle on the spot.

I have seen 2x speedups in casual benchmarks with small structures. As the
previous description shows, the difference in performance is going to be a
function of the nesting.

Note that that the involved methods are private and used only by permit.
2016-11-12 12:39:30 +01:00
..
abstract Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
assertions Improve assert_response helper 2016-09-14 11:30:09 -04:00
controller significant speedup of AC::Parameters#permit 2016-11-12 12:39:30 +01:00
dispatch Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
fixtures Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
journey Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
lib/controller Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
routing applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
tmp
abstract_unit.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00