From 0eb7359cc775c9d4c8dad68dd9dbf38c9680071e Mon Sep 17 00:00:00 2001
From: shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Tue, 5 Sep 2017 04:48:19 +0000
Subject: add rb_hash_new_with_size()

Sometimes, size of a hash can be calcluated a priori.  By providing
such info to the constructor we can avoid unnecessary internal re-
allocations.  This can boost for instance creation of hash literals.
[Bug #13861]

Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 insns.def | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'insns.def')

diff --git a/insns.def b/insns.def
index ed9d450728..8abc5340cf 100644
--- a/insns.def
+++ b/insns.def
@@ -496,7 +496,7 @@ newhash
 {
     RUBY_DTRACE_CREATE_HOOK(HASH, num);
 
-    val = rb_hash_new();
+    val = rb_hash_new_with_size(num / 2);
 
     if (num) {
         rb_hash_bulk_insert(num, STACK_ADDR_FROM_TOP(num), val);
-- 
cgit v1.2.3

