aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/context.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-11-12 12:33:37 +0100
committerXavier Noria <fxn@hashref.com>2016-11-12 12:39:30 +0100
commit26dd9b26ab7317f94fd285245879e888344143b2 (patch)
treecab647453438470dd362e8caabe50b92b0f6ba29 /actionview/lib/action_view/context.rb
parent5647d85440c0f828a58088562c15c8cea368f59c (diff)
downloadrails-26dd9b26ab7317f94fd285245879e888344143b2.tar.gz
rails-26dd9b26ab7317f94fd285245879e888344143b2.tar.bz2
rails-26dd9b26ab7317f94fd285245879e888344143b2.zip
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.
Diffstat (limited to 'actionview/lib/action_view/context.rb')
0 files changed, 0 insertions, 0 deletions