diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-04-22 09:17:05 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-04-22 09:17:05 -0700 |
commit | 4a06cc9edd8ecc71392de457bc70b4bc79b162ed (patch) | |
tree | 1bd488e9f156dcaed4196a625b395f7fc27875ce /activesupport | |
parent | aa804b152fcafc9e50d122622e3eec4e75486848 (diff) | |
download | rails-4a06cc9edd8ecc71392de457bc70b4bc79b162ed.tar.gz rails-4a06cc9edd8ecc71392de457bc70b4bc79b162ed.tar.bz2 rails-4a06cc9edd8ecc71392de457bc70b4bc79b162ed.zip |
fix boot performance issue
Slight refactor to improve boot performance on some Ruby
implementations (for now).
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/evented_file_update_checker.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb index 6a02a838b7..21fdf7bb80 100644 --- a/activesupport/lib/active_support/evented_file_update_checker.rb +++ b/activesupport/lib/active_support/evented_file_update_checker.rb @@ -86,16 +86,6 @@ module ActiveSupport end class PathHelper - using Module.new { - refine Pathname do - def ascendant_of?(other) - self != other && other.ascend do |ascendant| - break true if self == ascendant - end - end - end - } - def xpath(path) Pathname.new(path).expand_path end @@ -112,7 +102,7 @@ module ActiveSupport lcsp = Pathname.new(paths[0]) paths[1..-1].each do |path| - until lcsp.ascendant_of?(path) + until ascendant_of?(lcsp, path) if lcsp.root? # If we get here a root directory is not an ascendant of path. # This may happen if there are paths in different drives on @@ -145,13 +135,21 @@ module ActiveSupport dir = dirs_sorted_by_nparts.shift dirs_sorted_by_nparts.reject! do |possible_descendant| - dir.ascendant_of?(possible_descendant) && descendants << possible_descendant + ascendant_of?(dir, possible_descendant) && descendants << possible_descendant end end # Array#- preserves order. dirs - descendants end + + private + + def ascendant_of?(base, other) + base != other && other.ascend do |ascendant| + break true if base == ascendant + end + end end end end |