From 9dce62bfcd950c6bd52f45e2f3eaac0a044130f9 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Fri, 23 Aug 2019 15:48:35 -0400 Subject: [PATCH 3/4] Remove dead code paths in rb_hash_initialize_copy Given that `RHASH_ST_TABLE_P(h)` is defined as `(!RHASH_AR_TABLE_P(h))` it shouldn't be possible for a hash to be neither of these, so there is no need for the removed `else if` blocks. --- hash.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hash.c b/hash.c index ee5dc0e004..aeddf44d34 100644 --- a/hash.c +++ b/hash.c @@ -2805,17 +2805,11 @@ rb_hash_initialize_copy(VALUE hash, VALUE hash2) if (RHASH_AR_TABLE_SIZE(hash)) rb_hash_rehash(hash); } - else if (RHASH_ST_TABLE_P(hash2)) { + else { RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(hash2))); if (RHASH_ST_TABLE(hash)->num_entries) rb_hash_rehash(hash); } - else if (RHASH_AR_TABLE_P(hash)) { - ar_clear(hash); - } - else if (RHASH_ST_TABLE_P(hash)) { - st_clear(RHASH_ST_TABLE(hash)); - } COPY_DEFAULT(hash, hash2); -- 2.21.0