提交 7ad26e8a 编写于 作者: A Aaron Patterson

generate fewer objects when grouping

上级 51703256
......@@ -134,11 +134,13 @@ def preload_one(association)
end
def grouped_records(association)
Hash[
records_by_reflection(association).map do |reflection, records|
[reflection, records.group_by { |record| association_klass(reflection, record) }]
reflection_records = records_by_reflection(association)
reflection_records.each_with_object({}) do |(reflection, records),h|
h[reflection] = records.group_by { |record|
association_klass(reflection, record)
}
end
]
end
def records_by_reflection(association)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册