diff --git a/hash.c b/hash.c index 42f2f993fb8de8..9c3164c96afdd4 100644 --- a/hash.c +++ b/hash.c @@ -4425,6 +4425,14 @@ rb_ident_hash_new(void) return hash; } +VALUE +rb_ident_hash_new_with_size(st_index_t size) +{ + VALUE hash = rb_hash_new(); + RHASH_ST_TABLE_SET(hash, st_init_table_with_size(&identhash, size)); + return hash; +} + st_table * rb_init_identtable(void) { diff --git a/internal/hash.h b/internal/hash.h index e1f83d5018eceb..f274cbbbd6a21c 100644 --- a/internal/hash.h +++ b/internal/hash.h @@ -83,6 +83,7 @@ int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval); int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg); int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg); extern st_table *rb_hash_st_table(VALUE hash); +VALUE rb_ident_hash_new_with_size(st_index_t size); static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h); static inline VALUE RHASH_IFNONE(VALUE h);