Skip to content

Commit a8fea2b

Browse files
committed
refactor: use cstr_to_string() instead of manually calling CStr::from_ptr(etc...)
1 parent 4641e4b commit a8fea2b

File tree

1 file changed

+1
-3
lines changed
  • gems/codetracer-ruby-recorder/ext/native_tracer/src

1 file changed

+1
-3
lines changed

gems/codetracer-ruby-recorder/ext/native_tracer/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,8 @@ unsafe fn to_value(recorder: &mut Recorder, val: VALUE, depth: usize) -> ValueRe
365365
return ValueRecord::Float { f, type_id };
366366
}
367367
if RB_SYMBOL_P(val) {
368-
let id = rb_sym2id(val);
369-
let name = CStr::from_ptr(rb_id2name(id)).to_str().unwrap_or("");
370368
return ValueRecord::String {
371-
text: name.to_string(),
369+
text: cstr_to_string(rb_id2name(rb_sym2id(val))).unwrap_or_default(),
372370
type_id: recorder.symbol_type_id,
373371
};
374372
}

0 commit comments

Comments
 (0)