Project

General

Profile

Actions

Feature #20177

open

Optimized $LOADED_FEATURES.include?

Added by palkan (Vladimir Dementyev) 12 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:116163]

Description

I'd like to propose adding the optimized $LOADED_FEATURES.include? (not the one provided by the Array class) for faster feature checks in large codebases (when there are thousands of entries in the features list). I hit this problem while working on require-hooks.

We can use the internal vm->loaded_features_realpaths Hash to achieve faster lookups (it's used by MRI's require / load mechanism).

Alternatively to overriding the #include? method, we can introduce a custom API similar to how $LOAD_PATH.resolve_feature_path has been introduced (e.g., $LOADED_FEATURES.feature_loaded?(path)); but since the behaviour is similar to Array#include?, I'd suggest re-using it (and stay backward compatible).

No data to display

Actions

Also available in: Atom PDF

Like2