diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-27 23:49:06 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-27 23:49:06 -0300 |
commit | 1abbd3ef6129e30f1bf1ef6a6b4478f0cc57a324 (patch) | |
tree | 507e2f3ac926e2f605ac73929fdd2a9d0afb2f54 | |
parent | 65684d76fd5b0a3a46b80c612a653307d2a8359f (diff) | |
parent | 2e0cd0f371bd8f2bf0908f5f4c8887b6faef0884 (diff) | |
download | rails-1abbd3ef6129e30f1bf1ef6a6b4478f0cc57a324.tar.gz rails-1abbd3ef6129e30f1bf1ef6a6b4478f0cc57a324.tar.bz2 rails-1abbd3ef6129e30f1bf1ef6a6b4478f0cc57a324.zip |
Merge pull request #21411 from byroot/perf-improvement-in-dependencies-loadable-constants
10X speed improvements for AS::Dependencies.loadable_constants_for_path
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index f76ef04f49..8215a3085e 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -421,13 +421,13 @@ module ActiveSupport #:nodoc: bases.each do |root| expanded_root = File.expand_path(root) - next unless %r{\A#{Regexp.escape(expanded_root)}(/|\\)} =~ expanded_path + next unless expanded_path.start_with?(expanded_root) - nesting = expanded_path[(expanded_root.size)..-1] - nesting = nesting[1..-1] if nesting && nesting[0] == ?/ - next if nesting.blank? + root_size = expanded_root.size + next if expanded_path[root_size] != ?/.freeze - paths << nesting.camelize + nesting = expanded_path[(root_size + 1)..-1] + paths << nesting.camelize unless nesting.blank? end paths.uniq! |