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

ruby-changes:42361

From: nobu <ko1@a...>
Date: Wed, 30 Mar 2016 17:21:23 +0900 (JST)
Subject: [ruby-changes:42361] nobu:r54435 (trunk): hash.c: init table with size

nobu	2016-03-30 17:21:18 +0900 (Wed, 30 Mar 2016)

  New Revision: 54435

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

  Log:
    hash.c: init table with size
    
    * hash.c (rb_hash_s_create): allocate internal table with the
      given size.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 54434)
+++ hash.c	(revision 54435)
@@ -692,6 +692,9 @@ rb_hash_s_create(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/hash.c#L692
     }
 
     hash = hash_alloc(klass);
+    if (argc > 0) {
+        RHASH(hash)->ntbl = st_init_table_with_size(&objhash, argc / 2);
+    }
     for (i=0; i<argc; i+=2) {
         rb_hash_aset(hash, argv[i], argv[i + 1]);
     }

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

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