Issue #5427 has been updated by Thomas Sawyer.


"After this patch `loaded_features` is kept sorted by basename without extension (/usr/lib/ruby/asdf.rb => asdf). When `rb_feature_p` start its check, it goes straight to the first item with matching basename (using binary search) and stops after last."

If I understand this correctly, this is not good behavior. See http://redmine.ruby-lang.org/issues/4969.

If you guys are worried about load speed, there are two things that can be done that will speed up things more than anything else. 1) use relative require in your libraries. That's easy, but it's up to the end developer. And 2) Allow `require`/`load` methods to specify the specific gem in which a file is to be found and keep an index of the gem locations. This later approach can be done in one of two ways, either by a) taking the first part of require path to be the gem name by default, or b) allowing the gem name as an option, e.g. `require 'foo', :from=>'foogem'`. Ruby's standard library can use 'ruby' as a special "gem" name.

----------------------------------------
Feature #5427: Not complex patch to improve `require` time (load.c)
http://redmine.ruby-lang.org/issues/5427

Author: Yura Sokolov
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Currently `loaded_features` are unsorted, so that `rb_feature_p` ought to iterate over all `loaded_features` to figure: is requested feature loaded?

After this patch `loaded_features` is kept sorted by basename without extension (/usr/lib/ruby/asdf.rb => asdf). When `rb_feature_p` start its check, it goes straight to the first item with matching basename (using binary search) and stops after last.

Methods `$LOADED_FEATURES.<<` and `$LOADED_FEATURES.push` are overriden to keep sort order. `push` accepts only 1 parameter, but it seems that no one pass more to it.

Currently I choose to consider characters of basename in right to left order, but it could be changed, I think.

https://gist.github.com/1272991
https://github.com/ruby/ruby/pull/51


-- 
http://redmine.ruby-lang.org