aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-22 14:55:58 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-22 14:55:58 -0700
commit18ae0656f527e790bdc827fe68e3f2edd541b3a4 (patch)
tree954a7fd17c2f88a322f7f9b4efac0eeb3b1d76ba /activerecord/lib/active_record
parent849274316dc136135c50895e898e294904fec7a2 (diff)
downloadrails-18ae0656f527e790bdc827fe68e3f2edd541b3a4.tar.gz
rails-18ae0656f527e790bdc827fe68e3f2edd541b3a4.tar.bz2
rails-18ae0656f527e790bdc827fe68e3f2edd541b3a4.zip
Don't calculate all in-place changes to determine if attribute_changed?
Calling `changed_attributes` will ultimately check if every mutable attribute has changed in place. Since this gets called whenever an attribute is assigned, it's extremely slow. Instead, we can avoid this calculation until we actually need it. Fixes #18029
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attribute_methods/dirty.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb
index 033e71f7b9..d5702accaf 100644
--- a/activerecord/lib/active_record/attribute_methods/dirty.rb
+++ b/activerecord/lib/active_record/attribute_methods/dirty.rb
@@ -76,6 +76,10 @@ module ActiveRecord
private
+ def changes_include?(attr_name)
+ super || attribute_changed_in_place?(attr_name)
+ end
+
def calculate_changes_from_defaults
@changed_attributes = nil
self.class.column_defaults.each do |attr, orig_value|