Project

General

Profile

Bug #16121 ยป 0003-Remove-dead-code-paths-in-rb_hash_initialize_copy.diff.txt

[PATCH 3/4] Remove dead code paths in rb_hash_initialize_copy - dylants (Dylan Thacker-Smith), 08/23/2019 07:55 PM

 
1
From 9dce62bfcd950c6bd52f45e2f3eaac0a044130f9 Mon Sep 17 00:00:00 2001
2
From: Dylan Thacker-Smith <Dylan.Smith@shopify.com>
3
Date: Fri, 23 Aug 2019 15:48:35 -0400
4
Subject: [PATCH 3/4] Remove dead code paths in rb_hash_initialize_copy
5

    
6
Given that `RHASH_ST_TABLE_P(h)` is defined as `(!RHASH_AR_TABLE_P(h))`
7
it shouldn't be possible for a hash to be neither of these, so there
8
is no need for the removed `else if` blocks.
9
---
10
 hash.c | 8 +-------
11
 1 file changed, 1 insertion(+), 7 deletions(-)
12

    
13
diff --git a/hash.c b/hash.c
14
index ee5dc0e004..aeddf44d34 100644
15
--- a/hash.c
16
+++ b/hash.c
17
@@ -2805,17 +2805,11 @@ rb_hash_initialize_copy(VALUE hash, VALUE hash2)
18
         if (RHASH_AR_TABLE_SIZE(hash))
19
 	    rb_hash_rehash(hash);
20
     }
21
-    else if (RHASH_ST_TABLE_P(hash2)) {
22
+    else {
23
         RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(hash2)));
24
         if (RHASH_ST_TABLE(hash)->num_entries)
25
             rb_hash_rehash(hash);
26
     }
27
-    else if (RHASH_AR_TABLE_P(hash)) {
28
-        ar_clear(hash);
29
-    }
30
-    else if (RHASH_ST_TABLE_P(hash)) {
31
-        st_clear(RHASH_ST_TABLE(hash));
32
-    }
33
 
34
     COPY_DEFAULT(hash, hash2);
35
 
36
-- 
37
2.21.0
38