Skip to content

Commit

Permalink
Reduce array allocations from StaticFile#path (#8083)
Browse files Browse the repository at this point in the history
Merge pull request 8083
  • Loading branch information
ashmaroli committed Mar 30, 2020
1 parent 539e712 commit f0ab099
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/jekyll/static_file.rb
Expand Up @@ -40,11 +40,13 @@ def initialize(site, base, dir, name, collection = nil)

# Returns source file path.
def path
# Static file is from a collection inside custom collections directory
if !@collection.nil? && !@site.config["collections_dir"].empty?
File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact)
else
File.join(*[@base, @dir, @name].compact)
@path ||= begin
# Static file is from a collection inside custom collections directory
if !@collection.nil? && !@site.config["collections_dir"].empty?
File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact)
else
File.join(*[@base, @dir, @name].compact)
end
end
end

Expand Down

0 comments on commit f0ab099

Please sign in to comment.