lib/core: Optimized generation of Boxes in to_s_with_copy