mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fix boot performance issue
Slight refactor to improve boot performance on some Ruby implementations (for now).
This commit is contained in:
parent
aa804b152f
commit
4a06cc9edd
1 changed files with 10 additions and 12 deletions
|
@ -86,16 +86,6 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
|
|
||||||
class PathHelper
|
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)
|
def xpath(path)
|
||||||
Pathname.new(path).expand_path
|
Pathname.new(path).expand_path
|
||||||
end
|
end
|
||||||
|
@ -112,7 +102,7 @@ module ActiveSupport
|
||||||
lcsp = Pathname.new(paths[0])
|
lcsp = Pathname.new(paths[0])
|
||||||
|
|
||||||
paths[1..-1].each do |path|
|
paths[1..-1].each do |path|
|
||||||
until lcsp.ascendant_of?(path)
|
until ascendant_of?(lcsp, path)
|
||||||
if lcsp.root?
|
if lcsp.root?
|
||||||
# If we get here a root directory is not an ascendant of path.
|
# If we get here a root directory is not an ascendant of path.
|
||||||
# This may happen if there are paths in different drives on
|
# This may happen if there are paths in different drives on
|
||||||
|
@ -145,13 +135,21 @@ module ActiveSupport
|
||||||
dir = dirs_sorted_by_nparts.shift
|
dir = dirs_sorted_by_nparts.shift
|
||||||
|
|
||||||
dirs_sorted_by_nparts.reject! do |possible_descendant|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
# Array#- preserves order.
|
# Array#- preserves order.
|
||||||
dirs - descendants
|
dirs - descendants
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def ascendant_of?(base, other)
|
||||||
|
base != other && other.ascend do |ascendant|
|
||||||
|
break true if base == ascendant
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue