Project

General

Profile

Actions

Feature #5427

closed

Not complex patch to improve `require` time (load.c)

Added by funny_falcon (Yura Sokolov) over 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
-
[ruby-core:40073]

Description

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


Files

load.c.patch (6.8 KB) load.c.patch load.c patch against ruby-trunk funny_falcon (Yura Sokolov), 12/14/2011 05:59 PM
load.c.patch (6.67 KB) load.c.patch funny_falcon (Yura Sokolov), 12/16/2011 05:44 PM

Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Feature #7387: Keep LOADED_FEATURES sorted by filename without extention for faster lookup on require.Closedh.shirosaki (Hiroshi Shirosaki)11/19/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0