Skip to content

Commit b7165a3

Browse files
authored
Merge pull request rails#53680 from jdelStrother/file-update-checker
Make FileUpdateChecker faster with many extensions
2 parents 5d05082 + cea7280 commit b7165a3

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

activesupport/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@
2828

2929
*Taketo Takashima*
3030

31+
* Make `ActiveSupport::FileUpdateChecker` faster when checking many file-extensions.
32+
33+
*Jonathan del Strother*
34+
3135
Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/activesupport/CHANGELOG.md) for previous changes.

activesupport/lib/active_support/file_update_checker.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def initialize(files, dirs = {}, &block)
4747
end
4848

4949
@files = files.freeze
50-
@glob = compile_glob(dirs)
50+
@globs = compile_glob(dirs)
5151
@block = block
5252

5353
@watched = nil
@@ -103,7 +103,7 @@ def execute_if_updated
103103
def watched
104104
@watched || begin
105105
all = @files.select { |f| File.exist?(f) }
106-
all.concat(Dir[@glob]) if @glob
106+
all.concat(Dir[*@globs]) if @globs
107107
all.tap(&:uniq!)
108108
end
109109
end
@@ -145,10 +145,9 @@ def compile_glob(hash)
145145
hash.freeze # Freeze so changes aren't accidentally pushed
146146
return if hash.empty?
147147

148-
globs = hash.map do |key, value|
148+
hash.map do |key, value|
149149
"#{escape(key)}/**/*#{compile_ext(value)}"
150150
end
151-
"{#{globs.join(",")}}"
152151
end
153152

154153
def escape(key)

0 commit comments

Comments
 (0)