Actions
Feature #20177
openOptimized $LOADED_FEATURES.include?
Feature #20177: Optimized $LOADED_FEATURES.include?
Status:
Open
Assignee:
-
Target version:
-
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