diff options
author | Jean Boussier <[email protected]> | 2025-01-12 23:33:00 +0100 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-01-26 09:52:22 +0100 |
commit | d4a1a2780c39bc648496ac92fc6e6ce2eb38ab47 () | |
tree | 25373ac25d6bc78df93352b76528b9c57b651012 /load.c | |
parent | dd863714bf377b044645ea12b4db48920d49694e (diff) |
rb_feature_p: skip `get_expanded_load_path` for absolute paths
Ref: https://.com/fxn/zeitwerk/pull/308 ```ruby require 'benchmark' $LOAD_PATH << 'relative-path' autoload :FOO, '/tmp/foo.rb' puts Benchmark.realtime { 500_000.times do Object.autoload?(:FOO) end } ``` The above script takes 2.5 seconds on `master`, and only 50ms on this branch. When we're looking for a feature with an absolute path, we don't need to call the expensive `get_expanded_load_path`.
Notes: Merged: https://.com/ruby/ruby/pull/12562
-rw-r--r-- | load.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -597,7 +597,7 @@ rb_feature_p(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expa loading_tbl = get_loading_table(vm); f = 0; - if (!expanded) { struct loaded_feature_searching fs; fs.name = feature; fs.len = len; |