summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2022-07-22 11:04:43 -0400
committerPeter Zhu <peter@peterzhu.ca>2022-07-22 13:29:21 -0400
commite199ae3edcead0271c6da3410eb02acd927739b7 (patch)
tree6ba85447804f62b53a3c0ea983a464be6cce1610 /compile.c
parent203de45bd3635d262d301a3979e21238aa2c7909 (diff)
Remove reference counting for all frozen arrays
The RARRAY_LITERAL_FLAG was added in commit 5871ecf956711fcacad7c03f2aef95115ed25bc4 to improve CoW performance for array literals by not keeping track of reference counts. This commit reverts that commit and has an alternate implementation that is more generic for all frozen arrays. Since frozen arrays cannot be modified, we don't need to set the RARRAY_SHARED_ROOT_FLAG and we don't need to do reference counting.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6171
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index 7aca48d8dc..193a9a1c6d 100644
--- a/compile.c
+++ b/compile.c
@@ -4369,7 +4369,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_ary_len) {
/* The literal contains only optimizable elements, or the subarray is long enough */
- VALUE ary = rb_ary_literal_new(count);
+ VALUE ary = rb_ary_tmp_new(count);
/* Create a hidden array */
for (; count; count--, node = node->nd_next)
@@ -12349,7 +12349,7 @@ ibf_load_object_array(const struct ibf_load *load, const struct ibf_object_heade
const long len = (long)ibf_load_small_value(load, &reading_pos);
- VALUE ary = header->internal ? rb_ary_literal_new(len) : rb_ary_new_capa(len);
+ VALUE ary = header->frozen ? rb_ary_tmp_new(len) : rb_ary_new_capa(len);
int i;
for (i=0; i<len; i++) {