Hello,

rb_require (safe) uses search_required to determine if a feature was
already loaded

search_required will use rb_feature_p multiple times (depending on
extension) to determine if the feature requested is already in
$LOADED_FEATURES

rb_feature_p will expand $LOAD_PATH on every single time it is invoked.

If feature is not found, either rb_find_file_safe or
rb_find_file_ext_safe will be invoked which will also expand
$LOAD_PATH and iterate over it.

This means that for a simple, empty Rails application with 63 elements
in $LOAD_PATH and around 704 $LOADED_FEATURES path will be expanded
more than hundred thousand times.

Yes, more than 100_000 times.

Considering search_required, rb_feature_p and rb_find_file_* aren't "public":

Wouldn't be possible cache the first time $LOAD_PATH was expanded and
refer to it on subsequent calls?

Similar to what rb_feature_p does (load.c, line 160) but extended
across the other functions?

It will require the change of signature of these functions, but
wouldn't be worth it?

Or is a bad idea? If so, could you mind sharing why?

Thank you in advance for your time.
-- 
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupy