From 6f6aff56b11d7f3df9b446b9399cc546875e07f5 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Mon, 8 Jul 2024 14:10:11 -0400 Subject: [PATCH] Don't shrink array in `ary_make_shared` This change adds back the assertions removed in #11092 and removes the call to `ary_shrink_capa` from `ary_make_shared` when the array is frozen. --- array.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/array.c b/array.c index 7767ae04c6..4084876b42 100644 --- a/array.c +++ b/array.c @@ -149,6 +149,7 @@ should_be_T_ARRAY(VALUE ary) #define ARY_SET_CAPA(ary, n) do { \ RUBY_ASSERT(!ARY_EMBED_P(ary)); \ RUBY_ASSERT(!ARY_SHARED_P(ary)); \ + RUBY_ASSERT(!OBJ_FROZEN(ary)); \ RARRAY(ary)->as.heap.aux.capa = (n); \ } while (0) @@ -369,6 +370,7 @@ ary_heap_free(VALUE ary) static size_t ary_heap_realloc(VALUE ary, size_t new_capa) { + RUBY_ASSERT(!OBJ_FROZEN(ary)); SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, new_capa, ARY_HEAP_CAPA(ary)); ary_verify(ary); @@ -926,9 +928,6 @@ ary_make_shared(VALUE ary) return ary; } else if (OBJ_FROZEN(ary)) { - if (!ARY_EMBED_P(ary)) { - ary_shrink_capa(ary); - } return ary; } else {