[前][次][番号順一覧][スレッド一覧]

ruby-changes:43823

From: nobu <ko1@a...>
Date: Sun, 14 Aug 2016 22:35:48 +0900 (JST)
Subject: [ruby-changes:43823] nobu:r55896 (trunk): id_table.c: extend, don't shrink

nobu	2016-08-14 22:35:42 +0900 (Sun, 14 Aug 2016)

  New Revision: 55896

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55896

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/id_table.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55895)
+++ ChangeLog	(revision 55896)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Aug 14 22:35:40 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* id_table.c (hash_table_extend): should not shrink the table than
+	  the previous capacity.  [ruby-core:76534] [Bug #12614]
+
 Sun Aug 14 18:51:24 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* gems/bundled_gems: add gemified tk 0.1.0.
Index: id_table.c
===================================================================
--- id_table.c	(revision 55895)
+++ id_table.c	(revision 55896)
@@ -1311,6 +1311,9 @@ hash_table_extend(struct hash_id_table* https://github.com/ruby/ruby/blob/trunk/id_table.c#L1311
 	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++) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]