diff options
author | Alan Wu <[email protected]> | 2024-11-29 15:58:46 -0500 |
---|---|---|
committer | Alan Wu <[email protected]> | 2024-11-29 16:45:22 -0500 |
commit | 2fc357c16d2b10f5a9058063c78c308d34101921 (patch) | |
tree | ce45ed7bec476f0a7f558ef8a1cf147f109d69fd /yjit/src/codegen.rs | |
parent | 36a98307aa014a83778d4a6bb9f6c898345833f0 (diff) |
YJIT: Avoid std::ffi::CString with rb_intern2() during boot
Fewer allocations on boot, too.
Suggested-by: https://github.com/ruby/ruby/pull/12217
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12220
Diffstat (limited to 'yjit/src/codegen.rs')
-rw-r--r-- | yjit/src/codegen.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 07c8d726d9..acafa8979d 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -10737,13 +10737,12 @@ pub fn yjit_reg_method_codegen_fns() { /// and do not make method calls. /// /// See also: [lookup_cfunc_codegen]. -fn reg_method_codegen(klass: VALUE, mid_str: &str, gen_fn: MethodGenFn) { - let id_string = std::ffi::CString::new(mid_str).expect("couldn't convert to CString!"); - let mid = unsafe { rb_intern(id_string.as_ptr()) }; +fn reg_method_codegen(klass: VALUE, method_name: &str, gen_fn: MethodGenFn) { + let mid = unsafe { rb_intern2(method_name.as_ptr().cast(), method_name.len().try_into().unwrap()) }; let me = unsafe { rb_method_entry_at(klass, mid) }; if me.is_null() { - panic!("undefined optimized method!: {mid_str}"); + panic!("undefined optimized method!: {method_name}"); } // For now, only cfuncs are supported (me->cme cast fine since it's just me->def->type). |