Reduce array allocations from `StaticFile#path` (#8083)

Merge pull request 8083
This commit is contained in:
Ashwin Maroli 2020-03-30 20:14:04 +05:30 committed by GitHub
parent 539e712c41
commit f0ab09968e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

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