aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-30 08:21:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-30 08:21:18 +0000
commit29e324508aa85bbd1aff0fcc422c0ecc1dc6da4d (patch)
treea33c2b11be23b7a348d08d21d41375c4bc25a55c /hash.c
parent81e7caf718b25b43e1209a50d221e5e97f8b4b4f (diff)
downloadruby-29e324508aa85bbd1aff0fcc422c0ecc1dc6da4d.tar.gz
hash.c: init table with size
* hash.c (rb_hash_s_create): allocate internal table with the given size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index fa323a1f4e..dfc54f0bb9 100644
--- a/hash.c
+++ b/hash.c
@@ -692,6 +692,9 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
}
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]);
}