diff --git a/hash.c b/hash.c index ce7f5215d0..f49f881990 100644 --- a/hash.c +++ b/hash.c @@ -725,7 +725,8 @@ ar_force_convert_table(VALUE hash, const char *file, int line) return RHASH_ST_TABLE(hash); } - if (RHASH_AR_TABLE(hash)) { + RUBY_ASSERT(RHASH_AR_TABLE(hash)); + { unsigned i, bound = RHASH_AR_TABLE_BOUND(hash); rb_st_init_existing_table_with_size(new_tab, &objhash, RHASH_AR_TABLE_SIZE(hash)); @@ -738,9 +739,6 @@ ar_force_convert_table(VALUE hash, const char *file, int line) } ar_free_and_clear_table(hash); } - else { - rb_st_init_existing_table_with_size(new_tab, &objhash, 0); - } RHASH_ST_TABLE_SET(hash, new_tab); diff --git a/internal/hash.h b/internal/hash.h index c0baaa9dc9..d1848e5408 100644 --- a/internal/hash.h +++ b/internal/hash.h @@ -124,12 +124,14 @@ RHASH_AR_TABLE_P(VALUE h) return ! FL_TEST_RAW(h, RHASH_ST_TABLE_FLAG); } +RBIMPL_ATTR_RETURNS_NONNULL() static inline struct ar_table_struct * RHASH_AR_TABLE(VALUE h) { return (struct ar_table_struct *)((uintptr_t)h + sizeof(struct RHash)); } +RBIMPL_ATTR_RETURNS_NONNULL() static inline st_table * RHASH_ST_TABLE(VALUE h) {