diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2022-04-22 15:08:19 +0100 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2022-04-26 16:12:47 +0200 |
commit | 4a2b5102c11978b66d003ecbc8710b2f587b7322 (patch) | |
tree | 9164539b65fc3be414aeb04aa5c7bf8a1fd96774 /hash.c | |
parent | 5ce0d2aa354eb996cb3ca9bb944f880ff6acfd57 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5835
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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) { |