aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorBlake Mesdag <blakemesdag@gmail.com>2016-04-12 08:29:33 -0400
committerBlake Mesdag <blakemesdag@gmail.com>2016-04-12 08:41:06 -0400
commita8c99a25802cd46b92800fd2ab1030011f8942f4 (patch)
treea5d1e81cb5bfe855cdaf5a6fae3ed0dc186442ca /activesupport
parentdb9bc8097399aab9c866175b12e9e099b6c83ffa (diff)
downloadrails-a8c99a25802cd46b92800fd2ab1030011f8942f4.tar.gz
rails-a8c99a25802cd46b92800fd2ab1030011f8942f4.tar.bz2
rails-a8c99a25802cd46b92800fd2ab1030011f8942f4.zip
Use a single memoized loop to find max mtime in ActiveSupport::FileUpdateChecker#max_mtime
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index 8708a502e6..eaa5fc56a7 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -112,7 +112,18 @@ module ActiveSupport
# reloading is not triggered.
def max_mtime(paths)
time_now = Time.now
- paths.map {|path| File.mtime(path)}.reject {|mtime| time_now < mtime}.max
+ time_at_zero = Time.at(0)
+ max_time = time_at_zero
+
+ paths.each do |path|
+ time = File.mtime(path)
+
+ if time < time_now && time > max_time
+ max_time = time
+ end
+ end
+
+ max_time.object_id == time_at_zero.object_id ? nil : max_time
end
def compile_glob(hash)