summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2022-04-22 15:08:19 +0100
committerJean Boussier <jean.boussier@gmail.com>2022-04-26 16:12:47 +0200
commit4a2b5102c11978b66d003ecbc8710b2f587b7322 (patch)
tree9164539b65fc3be414aeb04aa5c7bf8a1fd96774 /hash.c
parent5ce0d2aa354eb996cb3ca9bb944f880ff6acfd57 (diff)
downloadruby-4a2b5102c11978b66d003ecbc8710b2f587b7322.tar.gz
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.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 6 insertions, 0 deletions
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)
{