New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AM::MassAssingmentSecurity: improve performance #5431

merged 1 commit into from Mar 14, 2012


None yet
2 participants

bogdan commented Mar 14, 2012

According to this article:

Current implementation of mass assignment security takes a lot of processor time because spawning to many redundant objects in MassAssignmentSecuritySanitizer#debug_protected_attribute_removal

We can get rid of this method.


----------when something sanitized----------
New:   0.010000   0.000000   0.010000 (  0.006924)
Old:   0.010000   0.000000   0.010000 (  0.009284)
----------when nothing sanitized----------
New:   0.010000   0.000000   0.010000 (  0.003906)
Old:   0.000000   0.000000   0.000000 (  0.005500) 

A little side effect of this patch attributes are processed one by one. Instead of:

      def process_removed_attributes(attrs)

We get:

      def process_removed_attribute(attr)

The only one place where this could cause side effect is when someone wants to create it's own sanitizer(other than built-in Strict and Logger).

We can make a backward compatibility for this but decided that it doesn't make that much sense.

josevalim added a commit that referenced this pull request Mar 14, 2012

Merge pull request #5431 from bogdan/mas_performance
AM::MassAssingmentSecurity: improve performance

@josevalim josevalim merged commit cc1c4ac into rails:master Mar 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment