1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make #deep_dup use #allocate instead of #new

This change preserves the speedup made in a24912cb1d (by avoiding
the wasted shallow dup of @attributes) while ensuring that the
performance of #deep_dup won't be tied to the performance of #initialize
This commit is contained in:
Michael Lovitt 2017-05-25 17:14:33 -05:00
parent 63dd12b7b8
commit fb6ccce806

View file

@ -64,7 +64,9 @@ module ActiveRecord
end
def deep_dup
self.class.new(attributes.deep_dup)
self.class.allocate.tap do |copy|
copy.instance_variable_set(:@attributes, attributes.deep_dup)
end
end
def initialize_dup(_)