提交 40599d1d 编写于 作者: K Kasper Timm Hansen

Stop mutating return value.

`PartialRenderer.render_collection_with/without_template` returns an array
of rendered partials. Avoid dup'ing and shifting it by indexing into
the collection instead.
上级 42fd563f
......@@ -18,11 +18,12 @@ def cache_collection_render
cached_partials = collection_cache.read_multi(*keyed_collection.keys)
@collection = keyed_collection.reject { |key, _| cached_partials.key?(key) }.values
rendered_partials = @collection.any? ? yield.dup : []
rendered_partials = @collection.any? ? yield : []
index = 0
keyed_collection.map do |cache_key, _|
cached_partials.fetch(cache_key) do
rendered_partials.shift
rendered_partials[index].tap { index += 1 }
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册