The array literal uses a duparray instruction. Before this patch, rb_ary_resurrect would malloc and memcpy a new array buffer. This
patch changes rb_ary_resurrect to use ary_make_partial so that the
new array object shares the underlying buffer with the array stored in
the instruction sequences.
Before this patch, the new array object is not shared:
Use a shared array for the
duparray
instructionIn this example code:
The array literal uses a
duparray
instruction. Before this patch,rb_ary_resurrect
would malloc and memcpy a new array buffer. Thispatch changes
rb_ary_resurrect
to useary_make_partial
so that thenew array object shares the underlying buffer with the array stored in
the instruction sequences.
Before this patch, the new array object is not shared:
After this patch:
[Feature #15289] [ruby-core:90097]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e