8000 merge revision(s) d4a1a2780c39bc648496ac92fc6e6ce2eb38ab47: [Backport… · github/ruby@54dd27d · GitHub
[go: up one dir, main page]

Skip to content

Commit 54dd27d

Browse files
committed
merge revision(s) d4a1a27: [Backport #21032]
rb_feature_p: skip `get_expanded_load_path` for absolute paths Ref: fxn/zeitwerk#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`.
1 parent 8274b81 commit 54dd27d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

load.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ rb_feature_p(rb_vm_t *vm, const char *feature, const char *ext, int rb, int expa
596596

597597
loading_tbl = get_loading_table(vm);
598598
f = 0;
599-
if (!expanded) {
599+
if (!expanded && !rb_is_absolute_path(feature)) {
600600
struct loaded_feature_searching fs;
601601
fs.name = feature;
602602
fs.len = len;

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 7
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 125
14+
#define RUBY_PATCHLEVEL 126
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)
0