aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2019-07-02 10:33:40 +0100
committerAaron Patterson <tenderlove@github.com>2020-01-06 12:41:33 -0800
commitb0bf654c3164e9c6b5b38aa6fe23bd76d28a38d2 (patch)
tree366cde98746dde84c48aa6a6d77c92b9713e47b6 /variable.c
parent95d23f36ff7be45bdca84c9ff6252593e73374a3 (diff)
downloadruby-b0bf654c3164e9c6b5b38aa6fe23bd76d28a38d2.tar.gz
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.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/variable.c b/variable.c
index 46f7dea725..1db061454b 100644
--- a/variable.c
+++ b/variable.c
@@ -896,8 +896,7 @@ iv_index_tbl_newsize(struct ivar_update *ivup)
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;