From 4a2b5102c11978b66d003ecbc8710b2f587b7322 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 22 Apr 2022 15:08:19 +0100 Subject: Expose `rb_hash_new_capa(long)` [Feature #18683] This allows parsers and similar libraries to create Hashes of a certain capacity in advance. It's useful when the key and values are streamed, hence `bulk_insert()` can't be used. --- hash.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'hash.c') diff --git a/hash.c b/hash.c index da85fd35c6..1f2bca12b3 100644 --- a/hash.c +++ b/hash.c @@ -1575,6 +1575,12 @@ rb_hash_new_with_size(st_index_t size) return ret; } +VALUE +rb_hash_new_capa(long capa) +{ + return rb_hash_new_with_size((st_index_t)capa); +} + static VALUE hash_copy(VALUE ret, VALUE hash) { -- cgit v1.2.1