Issue #5427 has been updated by Yura Sokolov.


Nikolai Weibull wrote:
> Yura Sokolov wrote:
>> Sorry, you are right, I confused `require_relative 'somelib'` with `require './somelib'`.
>> `require_relative` still gains improvement from this patch
> I don”Ēt think Thomas was talking about speed change in require_relative thanks to your suggested changes,
> rather that one should use require_relative regardless of your patch, as require_relative is a lot faster.

Sorry again, I thought it was clear when I said "sorry" first time I admit this fact.
Thank you for reprimand.
----------------------------------------
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