Jekyll::Cleaner#existing_files: Call keep_file_regex and keep_dirs only once, not per iteration
This commit is contained in:
parent
221c0b62b6
commit
15c4d9bee2
|
@ -36,9 +36,14 @@ module Jekyll
|
||||||
# Returns a Set with the file paths
|
# Returns a Set with the file paths
|
||||||
def existing_files
|
def existing_files
|
||||||
files = Set.new
|
files = Set.new
|
||||||
|
regex = keep_file_regex
|
||||||
|
dirs = keep_dirs
|
||||||
|
|
||||||
Dir.glob(site.in_dest_dir("**", "*"), File::FNM_DOTMATCH) do |file|
|
Dir.glob(site.in_dest_dir("**", "*"), File::FNM_DOTMATCH) do |file|
|
||||||
files << file unless file =~ /\/\.{1,2}$/ || file =~ keep_file_regex || keep_dirs.include?(file)
|
next if file =~ /\/\.{1,2}$/ || file =~ regex || dirs.include?(file)
|
||||||
|
files << file
|
||||||
end
|
end
|
||||||
|
|
||||||
files
|
files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,9 +98,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the regular expression
|
# Returns the regular expression
|
||||||
def keep_file_regex
|
def keep_file_regex
|
||||||
or_list = site.keep_files.join("|")
|
Regexp.union(site.keep_files)
|
||||||
pattern = "\/(#{or_list.gsub(".", "\.")})"
|
|
||||||
Regexp.new pattern
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue