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

ruby-changes:59640

From: Aaron <ko1@a...>
Date: Tue, 7 Jan 2020 05:41:58 +0900 (JST)
Subject: [ruby-changes:59640] b0bf654c31 (master): always expand ivar arrays to max width

https://git.ruby-lang.org/ruby.git/commit/?id=b0bf654c31

From b0bf654c3164e9c6b5b38aa6fe23bd76d28a38d2 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Tue, 2 Jul 2019 10:33:40 +0100
Subject: always expand ivar arrays to max width

If the instance variable table hasn't been "expanded", allocate the
maximum size of the ivar table.  This operates under the assumption that
most objects will eventually expand their ivar array to the maximum
width anyway, so we may as well avoid realloc calls.

diff --git a/variable.c b/variable.c
index 46f7dea..1db0614 100644
--- a/variable.c
+++ b/variable.c
@@ -896,8 +896,7 @@ iv_index_tbl_newsize(struct ivar_update *ivup) https://github.com/ruby/ruby/blob/trunk/variable.c#L896
     uint32_t index = (uint32_t)ivup->index;	/* should not overflow */
     uint32_t newsize = (index+1) + (index+1)/4; /* (index+1)*1.25 */
 
-    if (!ivup->iv_extended &&
-        ivup->u.iv_index_tbl->num_entries < (st_index_t)newsize) {
+    if (!ivup->iv_extended) {
         newsize = (uint32_t)ivup->u.iv_index_tbl->num_entries;
     }
     return newsize;
-- 
cgit v0.10.2


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

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