summaryrefslogtreecommitdiff
path: root/id_table.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-26 19:01:49 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-26 19:01:49 +0000
commit2d17694de73433900c92e8c9bec854c9e52b5ac3 (patch)
tree0cb49e508aaca5626babb87af4b9d7020d8b097e /id_table.c
parentea5e22d102a357114846874c2ff641f4a18dbdf1 (diff)
merge revision(s) 55896: [Backport #12614]
* id_table.c (hash_table_extend): should not shrink the table than the previous capacity. [ruby-core:76534] [Bug #12614] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@56019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'id_table.c')
-rw-r--r--id_table.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/id_table.c b/id_table.c
index 13adf6babb..423b00669b 100644
--- a/id_table.c
+++ b/id_table.c
@@ -1302,6 +1302,9 @@ hash_table_extend(struct hash_id_table* tbl)
int i;
item_t* old;
struct hash_id_table tmp_tbl = {0, 0, 0};
+ if (new_cap < tbl->capa) {
+ new_cap = round_capa(tbl->used + (tbl->used >> 1));
+ }
tmp_tbl.capa = new_cap;
tmp_tbl.items = ZALLOC_N(item_t, new_cap);
for (i = 0; i < tbl->capa; i++) {