Skip to content

Commit

Permalink
Memoize destination of pages, documents and staticfiles (#8458)
Browse files Browse the repository at this point in the history
Merge pull request 8458
  • Loading branch information
ashmaroli committed Nov 6, 2020
1 parent 56d59a1 commit 920c6f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
15 changes: 9 additions & 6 deletions lib/jekyll/document.rb
Expand Up @@ -257,13 +257,16 @@ def [](key)
#
# Returns the full path to the output file of this document.
def destination(base_directory)
path = site.in_dest_dir(base_directory, URL.unescape_path(url))
if url.end_with? "/"
path = File.join(path, "index.html")
else
path << output_ext unless path.end_with? output_ext
@destination ||= {}
@destination[base_directory] ||= begin
path = site.in_dest_dir(base_directory, URL.unescape_path(url))
if url.end_with? "/"
path = File.join(path, "index.html")
else
path << output_ext unless path.end_with? output_ext
end
path
end
path
end

# Write the generated Document file to the destination directory.
Expand Down
11 changes: 7 additions & 4 deletions lib/jekyll/page.rb
Expand Up @@ -158,10 +158,13 @@ def relative_path
#
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index") if url.end_with?("/")
path << output_ext unless path.end_with? output_ext
path
@destination ||= {}
@destination[dest] ||= begin
path = site.in_dest_dir(dest, URL.unescape_path(url))
path = File.join(path, "index") if url.end_with?("/")
path << output_ext unless path.end_with? output_ext
path
end
end

# Returns the object as a debug String.
Expand Down
3 changes: 2 additions & 1 deletion lib/jekyll/static_file.rb
Expand Up @@ -55,7 +55,8 @@ def path
#
# Returns destination file path.
def destination(dest)
@site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
@destination ||= {}
@destination[dest] ||= @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
end

def destination_rel_dir
Expand Down

0 comments on commit 920c6f4

Please sign in to comment.