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:
parent
63dd12b7b8
commit
fb6ccce806
1 changed files with 3 additions and 1 deletions
|
@ -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(_)
|
||||
|
|
Loading…
Reference in a new issue