Skip to content
This repository
Browse code

instance_methods includes public and protected, so reduce funcalls an…

…d object allocs
  • Loading branch information...
commit 289cc15f1a89a179116f67e5f666f4ff6d645f03 1 parent 8657826
Aaron Patterson tenderlove authored

Showing 1 changed file with 2 additions and 3 deletions. Show diff stats Hide diff stats

  1. +2 3 activerecord/lib/active_record/attribute_methods.rb
5 activerecord/lib/active_record/attribute_methods.rb
@@ -31,9 +31,8 @@ def instance_method_already_implemented?(method_name)
31 31 def defined_activerecord_methods
32 32 active_record = ActiveRecord::Base
33 33 super_klass = ActiveRecord::Base.superclass
34   - methods = active_record.public_instance_methods - super_klass.public_instance_methods
35   - methods += active_record.private_instance_methods - super_klass.private_instance_methods
36   - methods += active_record.protected_instance_methods - super_klass.protected_instance_methods
  34 + methods = (active_record.instance_methods - super_klass.instance_methods) +
  35 + (active_record.private_instance_methods - super_klass.private_instance_methods)
37 36 methods.map {|m| m.to_s }.to_set
38 37 end
39 38 end

0 comments on commit 289cc15

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