aboutsummaryrefslogtreecommitdiffstats
path: root/id_table.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-14 13:35:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-14 13:35:42 +0000
commitdfe1d4fda6521729ff3536b53cb2cdc9a034a015 (patch)
treeab9f1d79328646033e61e79e10d7cdd7706a6ee8 /id_table.c
parent6418594993d90e4218411153f351d1d7be3e8502 (diff)
downloadruby-dfe1d4fda6521729ff3536b53cb2cdc9a034a015.tar.gz
id_table.c: extend, don't shrink
* 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/trunk@55896 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 1d1d684745..f0f37cc913 100644
--- a/id_table.c
+++ b/id_table.c
@@ -1311,6 +1311,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++) {