variable.c (const_get): avoid mrb_funcall if possible

Directly call mrb_const_missing() if const_missing is not overridden.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-06-12 23:47:35 +09:00
parent 89f7bb1056
commit 17720c9b7b
3 changed files with 19 additions and 8 deletions
+5 -1
View File
@@ -785,8 +785,12 @@ L_RETRY:
retry = TRUE;
goto L_RETRY;
}
mrb_value mod = mrb_obj_value(base);
if (mrb_func_basic_p(mrb, mod, MRB_SYM(const_missing), mrb_mod_const_missing)) {
return mrb_const_missing(mrb, mod, sym);
}
mrb_value name = mrb_symbol_value(sym);
return mrb_funcall_argv(mrb, mrb_obj_value(base), MRB_SYM(const_missing), 1, &name);
return mrb_funcall_argv(mrb, mod, MRB_SYM(const_missing), 1, &name);
}
MRB_API mrb_value