From 8e633e505880755e7e366ccec2210bbe2b5436e7 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 24 Sep 2015 11:50:11 -0600 Subject: Clean up the implementation of AR::Dirty This moves a bit more of the logic required for dirty checking into the attribute objects. I had hoped to remove the `with_value_from_database` stuff, but unfortunately just calling `dup` on the attribute objects isn't enough, since the values might contain deeply nested data structures. I think this can be cleaned up further. This makes most dirty checking become lazy, and reduces the number of object allocations and amount of CPU time when assigning a value. This opens the door (but doesn't quite finish) to improving the performance of writes to a place comparable to 4.1 --- activerecord/lib/active_record/attribute.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib/active_record/attribute.rb') diff --git a/activerecord/lib/active_record/attribute.rb b/activerecord/lib/active_record/attribute.rb index 73dd3fa041..21fe032a9c 100644 --- a/activerecord/lib/active_record/attribute.rb +++ b/activerecord/lib/active_record/attribute.rb @@ -55,6 +55,7 @@ module ActiveRecord end def with_value_from_user(value) + type.assert_valid_value(value) self.class.from_user(name, value, type) end -- cgit v1.2.3