未验证 提交 bc9fb9cf 编写于 作者: R Ryuta Kamizono 提交者: GitHub

Merge pull request #32497 from eugeneius/mutation_tracker_changed_attribute_names

Avoid generating full changes hash on every save
......@@ -11,6 +11,10 @@ def initialize(attributes)
@forced_changes = Set.new
end
def changed_attribute_names
attr_names.select { |attr_name| changed?(attr_name) }
end
def changed_values
attr_names.each_with_object({}.with_indifferent_access) do |attr_name, result|
if changed?(attr_name)
......@@ -76,6 +80,10 @@ def attr_names
class NullMutationTracker # :nodoc:
include Singleton
def changed_attribute_names(*)
[]
end
def changed_values(*)
{}
end
......
......@@ -114,7 +114,7 @@ def changes_to_save
# Alias for +changed+
def changed_attribute_names_to_save
changes_to_save.keys
mutations_from_database.changed_attribute_names
end
# Alias for +changed_attributes+
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册