From 522d4cd32f7727886f4fcbc28ed29c08d361ee20 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Sun, 28 Mar 2021 14:09:52 +0900 Subject: [PATCH] Force recycle intermediate collection in Hash#transform_keys! [Bug #17735] * Force recycle intermediate hash * Force recycle intermediate array too https://github.com/ruby/ruby/pull/4329#issuecomment-808840718 --- hash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hash.c b/hash.c index 17864a0fcd..60fad036c2 100644 --- a/hash.c +++ b/hash.c @@ -3294,7 +3294,9 @@ rb_hash_transform_keys_bang(int argc, VALUE *argv, VALUE hash) rb_hash_aset(new_keys, new_key, Qnil); } rb_ary_clear(pairs); + rb_gc_force_recycle(pairs); rb_hash_clear(new_keys); + rb_gc_force_recycle(new_keys); } return hash; }