mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user