aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/file_update_checker.rb
diff options
context:
space:
mode:
authorBlake Mesdag <blakemesdag@gmail.com>2016-04-12 13:29:56 -0400
committerBlake Mesdag <blakemesdag@gmail.com>2016-04-12 13:29:56 -0400
commitfad2428e357f5e88e745aa402e21cdfcb700fbc0 (patch)
tree3d6e299922a26846e0a9a9910ceeabfa755a4a7e /activesupport/lib/active_support/file_update_checker.rb
parentb0bce0b8ce807e4d92a8a01fa0235727d709c21d (diff)
downloadrails-fad2428e357f5e88e745aa402e21cdfcb700fbc0.tar.gz
rails-fad2428e357f5e88e745aa402e21cdfcb700fbc0.tar.bz2
rails-fad2428e357f5e88e745aa402e21cdfcb700fbc0.zip
More readable version
Diffstat (limited to 'activesupport/lib/active_support/file_update_checker.rb')
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb23
1 files changed, 10 insertions, 13 deletions
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index d1eb410c85..2a1a8f9797 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -114,30 +114,27 @@ module ActiveSupport
return nil if paths.empty?
time_now = Time.now
- max_time = nil
+ max_mtime = nil
paths.each do |path|
- time = File.mtime(path)
+ mtime = File.mtime(path)
- if max_time.nil?
- if time.compare_without_coercion(time_now) < 0
- max_time = time
- end
-
- next
- end
+ # Prevent dates in the future being considered
+ # Equivalent ruby:
+ # time.now < mtime
+ next if time_now.compare_without_coercion(mtime) < 0
# 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
+ # max_mtime.nil? || max_mtime < mtime
+ if max_mtime.nil? || max_mtime.compare_without_coercion(mtime) < 0
+ max_mtime = mtime
end
end
- max_time
+ max_mtime
end
def compile_glob(hash)