Skip to content

Commit 140bf4d

Browse files
committed
localize rb_vm_t and minimize times of GET_VM() calls
1 parent 2622d79 commit 140bf4d

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

load.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,21 +1149,23 @@ search_required(const rb_namespace_t *ns, VALUE fname, volatile VALUE *path, fea
11491149

11501150
// Check if it's a statically linked extension when
11511151
// not already a feature and not found as a dynamic library.
1152-
rb_vm_t *vm = GET_VM();
1153-
if (!ft && type != loadable_ext_rb && vm->static_ext_inits) {
1154-
VALUE lookup_name = tmp;
1155-
// Append ".so" if not already present so for example "etc" can find "etc.so".
1156-
// We always register statically linked extensions with a ".so" extension.
1157-
// See encinit.c and extinit.c (generated at build-time).
1158-
if (!ext) {
1159-
lookup_name = rb_str_dup(lookup_name);
1160-
rb_str_cat_cstr(lookup_name, ".so");
1161-
}
1162-
ftptr = RSTRING_PTR(lookup_name);
1163-
if (st_lookup(vm->static_ext_inits, (st_data_t)ftptr, NULL)) {
1164-
*path = rb_filesystem_str_new_cstr(ftptr);
1165-
RB_GC_GUARD(lookup_name);
1166-
return 's';
1152+
if (!ft && type != loadable_ext_rb) {
1153+
rb_vm_t *vm = GET_VM();
1154+
if (vm->static_ext_inits) {
1155+
VALUE lookup_name = tmp;
1156+
// Append ".so" if not already present so for example "etc" can find "etc.so".
1157+
// We always register statically linked extensions with a ".so" extension.
1158+
// See encinit.c and extinit.c (generated at build-time).
1159+
if (!ext) {
1160+
lookup_name = rb_str_dup(lookup_name);
1161+
rb_str_cat_cstr(lookup_name, ".so");
1162+
}
1163+
ftptr = RSTRING_PTR(lookup_name);
1164+
if (st_lookup(vm->static_ext_inits, (st_data_t)ftptr, NULL)) {
1165+
*path = rb_filesystem_str_new_cstr(ftptr);
1166+
RB_GC_GUARD(lookup_name);
1167+
return 's';
1168+
}
11671169
}
11681170
}
11691171

0 commit comments

Comments
 (0)