Browse files

instance_methods includes public and protected, so reduce funcalls an…

…d object allocs
  • Loading branch information...
1 parent 8657826 commit 289cc15f1a89a179116f67e5f666f4ff6d645f03 @tenderlove tenderlove committed Feb 19, 2011
Showing with 2 additions and 3 deletions.
  1. +2 −3 activerecord/lib/active_record/attribute_methods.rb
View
5 activerecord/lib/active_record/attribute_methods.rb
@@ -31,9 +31,8 @@ def instance_method_already_implemented?(method_name)
def defined_activerecord_methods
active_record = ActiveRecord::Base
super_klass = ActiveRecord::Base.superclass
- methods = active_record.public_instance_methods - super_klass.public_instance_methods
- methods += active_record.private_instance_methods - super_klass.private_instance_methods
- methods += active_record.protected_instance_methods - super_klass.protected_instance_methods
+ methods = (active_record.instance_methods - super_klass.instance_methods) +
+ (active_record.private_instance_methods - super_klass.private_instance_methods)
methods.map {|m| m.to_s }.to_set
end
end

0 comments on commit 289cc15

Please sign in to comment.