symbol.c: combine variable declaration with initialization

This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-25 15:39:32 +09:00
parent 0211004cf2
commit 516d2bcc52
+4 -7
View File
@@ -846,15 +846,12 @@ id:
static mrb_value
sym_inspect(mrb_state *mrb, mrb_value sym)
{
mrb_value str;
const char *name;
mrb_int len;
mrb_sym id = mrb_symbol(sym);
char *sp;
mrb_int len;
const char *name = mrb_sym_name_len(mrb, id, &len);
mrb_value str = mrb_str_new(mrb, NULL, len+1);
char *sp = RSTRING_PTR(str);
name = mrb_sym_name_len(mrb, id, &len);
str = mrb_str_new(mrb, NULL, len+1);
sp = RSTRING_PTR(str);
sp[0] = ':';
memcpy(sp+1, name, len);
mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);