Improve performance of ignoring files (#1971)
* Determine the type of ignore pattern once per pattern. Performing this work when checking when each file was ignored accounted for around 4.5 of the 6 seconds that processing ignored files was taking on a site with ~14,000 files and a small number of ignore patterns. After this change, processing ignored files takes less than 1.5 seconds. * Cache the normalized paths on Resource and SourceFile. Normalizing the paths is expensive, so avoid doing it multiple times. `Util::normalize_path` is marked as memoized, but this is not effective as: 1. `memoize` doesn't appear to work with module functions. 2. Checking whether we have a memoized value is as expensive as normalizing the path. This further drops the time it takes to process ignored files on a site with ~14,000 files from ~1.5 seconds to ~0.6 seconds.
This commit is contained in:
parent
c264b05906
commit
65462cbc43
4 changed files with 57 additions and 20 deletions
|
@ -8,6 +8,10 @@ module Middleman
|
|||
::Middleman::Sources.file_cache[full_path] ||= {}
|
||||
::Middleman::Sources.file_cache[full_path][version] ||= ::File.read(full_path)
|
||||
end
|
||||
|
||||
def normalized_relative_path
|
||||
@normalized_relative_path ||= ::Middleman::Util.normalize_path relative_path.to_s
|
||||
end
|
||||
end
|
||||
|
||||
# Sources handle multiple on-disk collections of files which make up
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue