From 148e33058cf4b8c6197bdc8c78b28bfd018d051f Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 25 Aug 2012 02:56:55 +0200 Subject: simplifies a regexp We simplify two things here: First since * is greedy it is enough to go look for the rightmost ::, no need to ask the regexp engine to match the rest of the string since we are not validating anything, only capturing. The second simplification comes from using a look-ahead assertion, that allows us to have the capture in $&, thus removing the need of a group. --- activesupport/lib/active_support/dependencies.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 5ce2a0bd08..d3a37f28c8 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -443,7 +443,7 @@ module ActiveSupport #:nodoc: def load_file(path, const_paths = loadable_constants_for_path(path)) log_call path, const_paths const_paths = [const_paths].compact unless const_paths.is_a? Array - parent_paths = const_paths.collect { |const_path| /(.*)::[^:]+\Z/ =~ const_path ? $1 : :Object } + parent_paths = const_paths.collect { |const_path| /.*(?=::)/ =~ const_path ? $& : :Object } result = nil newly_defined_paths = new_constants_in(*parent_paths) do -- cgit v1.2.3