aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/file_update_checker.rb
diff options
context:
space:
mode:
authorBlake Mesdag <blakemesdag@gmail.com>2016-04-12 09:46:25 -0400
committerBlake Mesdag <blakemesdag@gmail.com>2016-04-12 09:46:25 -0400
commitfcde948e43e07d2c4e32988e05f5920501a26364 (patch)
tree7fd46b0d69c341169ef470d0e7c2afcdd44ed8e2 /activesupport/lib/active_support/file_update_checker.rb
parenta8c99a25802cd46b92800fd2ab1030011f8942f4 (diff)
downloadrails-fcde948e43e07d2c4e32988e05f5920501a26364.tar.gz
rails-fcde948e43e07d2c4e32988e05f5920501a26364.tar.bz2
rails-fcde948e43e07d2c4e32988e05f5920501a26364.zip
Use Time#compare_without_coercion for super speed
Diffstat (limited to 'activesupport/lib/active_support/file_update_checker.rb')
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index eaa5fc56a7..4f0a2dedc5 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -118,7 +118,12 @@ module ActiveSupport
paths.each do |path|
time = File.mtime(path)
- if time < time_now && time > max_time
+ # 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