lib/faster_require.rb in faster_require-0.7.2 vs lib/faster_require.rb in faster_require-0.7.3

- old
+ new

@@ -182,10 +182,15 @@ relative_full_path = known_loc.sub(libs_path, '')[1..-1] # $LOADED_FEATURES << relative_full_path.gsub('.rb', '') # don't think you need this one $LOADED_FEATURES << relative_full_path # add in with .rb, too. # load(known_loc, false) # too slow - eval(File.open(known_loc, 'rb') {|f| f.read}, TOPLEVEL_BINDING, known_loc) # note the 'rb' here--this means it's reading .rb files as binary, which *typically* works...maybe unnecessary though? + contents = File.open(known_loc, 'rb') {|f| f.read} + if contents =~ /require_relative/ # =~ is faster than .include? it appears + load(known_loc, false) # slow, but dependent on a ruby core bug: http://redmine.ruby-lang.org/issues/4487 + else + eval(contents, TOPLEVEL_BINDING, known_loc) # note the 'rb' here--this means it's reading .rb files as binary, which *typically* works...maybe unnecessary though? + end ensure raise 'unexpected' unless IN_PROCESS.pop == known_loc end # --if it breaks re-save the offending file in binary mode, or file an issue on the tracker... return true