mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Performance optimization for AttributeSet#deep_dup
Skip the call to #dup, since it does a shallow copy of attributes, which is wasted effort, since #deep_dup then replaces that shallow copy with a #deep_dup of the given attributes. This change addresses slowness in ActiveRecord initialization introduced starting in Rails 5.0.
This commit is contained in:
parent
0fa9084a18
commit
a24912cb1d
1 changed files with 1 additions and 3 deletions
|
@ -64,9 +64,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def deep_dup
|
||||
dup.tap do |copy|
|
||||
copy.instance_variable_set(:@attributes, attributes.deep_dup)
|
||||
end
|
||||
self.class.new(attributes.deep_dup)
|
||||
end
|
||||
|
||||
def initialize_dup(_)
|
||||
|
|
Loading…
Reference in a new issue