Commit 8e99d39570
introduced a serious regression by encoding filenames within a "delete_if" block, meaning that every path in the list of all previously built files was re-encoded every time a file was built. For large projects this causes serious slowdowns - for a 4000 file test, it went from 14s to build to around 8 minutes to build. This change fixes the builder to only encode files when the file list is initially build, removing the bottleneck.
This commit is contained in:
parent
1f6904c0fc
commit
39a9331232
1 changed files with 6 additions and 6 deletions
|
@ -162,6 +162,11 @@ module Middleman::Cli
|
||||||
@to_clean += paths.select do |path|
|
@to_clean += paths.select do |path|
|
||||||
path.to_s !~ /\/\./ || path.to_s =~ /\.(htaccess|htpasswd)/
|
path.to_s !~ /\/\./ || path.to_s =~ /\.(htaccess|htpasswd)/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if RUBY_PLATFORM =~ /darwin/
|
||||||
|
# handle UTF-8-MAC filename on MacOS
|
||||||
|
@to_clean.map { |path| path.to_s.encode('UTF-8', 'UTF-8-MAC') }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Actually build the app
|
# Actually build the app
|
||||||
|
@ -206,12 +211,7 @@ module Middleman::Cli
|
||||||
output_path = render_to_file(resource)
|
output_path = render_to_file(resource)
|
||||||
|
|
||||||
if should_clean? && output_path.exist?
|
if should_clean? && output_path.exist?
|
||||||
if RUBY_PLATFORM =~ /darwin/
|
@to_clean.delete(output_path.realpath)
|
||||||
# handle UTF-8-MAC filename on MacOS
|
|
||||||
@to_clean.delete_if { |path| path.to_s.encode('UTF-8', 'UTF-8-MAC') == output_path.realpath.to_s }
|
|
||||||
else
|
|
||||||
@to_clean.delete(output_path.realpath)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue