1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
Kenichi Kamiya 2021-03-28 14:09:52 +09:00 committed by GitHub
parent 9af57eeed6
commit 522d4cd32f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2021-03-28 14:10:14 +09:00
Merged-By: nobu <nobu@ruby-lang.org>

2
hash.c
View file

@ -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;
}