cdump.c: use IREP_TT_SSTR for pool strings in mrbc -C output

pool strings generated by mrbc -C are C string literals inside
static const structs, which reside in ROM. mark them as
IREP_TT_SSTR (static) instead of IREP_TT_STR (dynamic) so the
VM uses mrb_str_new_static() and mrb_intern_static() instead of
mrb_str_new() and mrb_intern(). this avoids unnecessary
malloc+memcpy for string literals longer than the embed threshold,
especially on embedded platforms where mrb_ro_data_p() returns
FALSE.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-02-11 22:00:17 +09:00
parent 14a5cfb87f
commit 1de46b2051
+1 -1
View File
@@ -63,7 +63,7 @@ cdump_pool(mrb_state *mrb, const mrb_irep_pool *p, FILE *fp)
else { /* string */
int i, len = p->tt>>2;
const char *s = p->u.str;
fprintf(fp, "{IREP_TT_STR|(%d<<2), {\"", len);
fprintf(fp, "{IREP_TT_SSTR|(%d<<2), {\"", len);
for (i=0; i<len; i++) {
fprintf(fp, "\\x%02x", (int)s[i]&0xff);
}