From 6bcd433214f2211b5d4d6b537453bc4775e83a96 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 5 Nov 2025 08:23:36 +0900 Subject: [PATCH] mruby-string-ext: combine variable declaration with initialization --- mrbgems/mruby-string-ext/src/string.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mrbgems/mruby-string-ext/src/string.c b/mrbgems/mruby-string-ext/src/string.c index d5ce5c8f4..4e9c95d21 100644 --- a/mrbgems/mruby-string-ext/src/string.c +++ b/mrbgems/mruby-string-ext/src/string.c @@ -1644,14 +1644,13 @@ str_chars_ary(mrb_state *mrb, mrb_value self) struct RString *s = mrb_str_ptr(self); const unsigned char *p = (unsigned char*)RSTR_PTR(s); const unsigned char *e = p + RSTR_LEN(s); - mrb_value result; /* Estimate character count for array pre-allocation */ mrb_int estimated_chars = RSTR_LEN(s); if (!RSTR_SINGLE_BYTE_P(s) && !RSTR_BINARY_P(s)) { estimated_chars = estimated_chars / 2; /* rough estimate for UTF-8 */ } - result = mrb_ary_new_capa(mrb, estimated_chars); + mrb_value result = mrb_ary_new_capa(mrb, estimated_chars); if (RSTR_SINGLE_BYTE_P(s) || RSTR_BINARY_P(s)) { /* ASCII/Binary: each byte is a character */