mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
9d084b09b7
io_puts_str, io_puts_ary, and io_puts allocated a fresh mruby String for every "\n", empty-array marker, "[...]" overflow marker, and no-arg newline, only for fd_write to unpack it back to ptr/len. The allocations also stayed on the GC arena across the recursive walk, scaling pressure with array length. Split fd_write into fd_write_buf (the EINTR-resilient write loop over ptr/len) plus the existing mrb_value wrapper, and add a FD_WRITE_LIT macro for compile-time-known literals. Replace the four mrb_str_new_lit + fd_write pairs with FD_WRITE_LIT. The "" s "" inside the macro enforces that the argument is a string literal so sizeof(s) - 1 is the correct length. Co-authored-by: Claude <noreply@anthropic.com>