aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb18
1 files changed, 17 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..4f0a2dedc5 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -112,7 +112,23 @@ 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)
+
+ # This avoids ActiveSupport::CoreExt::Time#time_with_coercion
+ # which is super slow when comparing two Time objects
+ #
+ # Equivalent Ruby:
+ # time < time_now && time > max_time
+ if time.compare_without_coercion(time_now) < 0 && time.compare_without_coercion(max_time) > 0
+ max_time = time
+ end
+ end
+
+ max_time.object_id == time_at_zero.object_id ? nil : max_time
end
def compile_glob(hash)