1
0
Fork 0
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:
Michael Lovitt 2017-05-18 15:38:30 -05:00
parent 0fa9084a18
commit a24912cb1d

View file

@ -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(_)