Memoize the return value of Site#documents (#7273)

Merge pull request 7273
This commit is contained in:
Ashwin Maroli 2018-10-31 22:40:19 +05:30 committed by jekyllbot
parent 501d0253fa
commit f0af098abe
1 changed files with 2 additions and 1 deletions

View File

@ -97,6 +97,7 @@ module Jekyll
@post_attr_hash = {} @post_attr_hash = {}
@site_data = nil @site_data = nil
@collections = nil @collections = nil
@documents = nil
@docs_to_write = nil @docs_to_write = nil
@regenerator.clear_cache @regenerator.clear_cache
@liquid_renderer.reset @liquid_renderer.reset
@ -326,7 +327,7 @@ module Jekyll
# #
# Returns an Array of all Documents # Returns an Array of all Documents
def documents def documents
collections.reduce(Set.new) do |docs, (_, collection)| @documents ||= collections.reduce(Set.new) do |docs, (_, collection)|
docs + collection.docs + collection.files docs + collection.docs + collection.files
end.to_a end.to_a
end end