Share array entities if possible with ary.replace(frozen_ary)

Currently mruby is limited to always placing array entities on the rewritable heap.
Therefore, if the original array was frozen and only rewritable objects survived the subsequent process, the array entity can be changed.
If an array object that actually shared the array entity is frozen with `ary.freeze`, there should be no problem, since the shared state is still kept.
This commit is contained in:
dearblue
2025-07-18 22:51:00 +09:00
parent a5ac9f3671
commit 3c653fc0d4
+1 -1
View File
@@ -511,7 +511,7 @@ ary_replace(mrb_state *mrb, struct RArray *a, struct RArray *b)
mrb_write_barrier(mrb, (struct RBasic*)a);
return;
}
if (!mrb_frozen_p(b) && len > ARY_REPLACE_SHARED_MIN) {
if (len > ARY_REPLACE_SHARED_MIN) {
ary_make_shared(mrb, b);
goto shared_b;
}