diff options
author | Jean Boussier <byroot@ruby-lang.org> | 2023-10-10 13:12:17 +0200 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2023-10-10 14:47:54 +0200 |
commit | 5cc44f48c51974a84a40480477a4afd8901ae7e4 (patch) | |
tree | 9c252adf59e2e0b932a74a7d0cf000969039e97d /variable.c | |
parent | fd21460898d2d5044c1bcc140927142921424791 (diff) | |
download | ruby-5cc44f48c51974a84a40480477a4afd8901ae7e4.tar.gz |
Refactor rb_shape_transition_shape_capa to not accept capacity
This way the groth factor is encapsulated, which allows
rb_shape_transition_shape_capa to be smarter about ideal sizes.
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/variable.c b/variable.c index c30971bd08..15dc4831d8 100644 --- a/variable.c +++ b/variable.c @@ -1444,13 +1444,10 @@ rb_shape_t * rb_grow_iv_list(VALUE obj) { rb_shape_t * initial_shape = rb_shape_get_shape(obj); - uint32_t len = initial_shape->capacity; - RUBY_ASSERT(len > 0); - uint32_t newsize = (uint32_t)(len * 2); + RUBY_ASSERT(initial_shape->capacity > 0); + rb_shape_t * res = rb_shape_transition_shape_capa(initial_shape); - rb_shape_t * res = rb_shape_transition_shape_capa(initial_shape, newsize); - - rb_ensure_iv_list_size(obj, len, newsize); + rb_ensure_iv_list_size(obj, initial_shape->capacity, res->capacity); rb_shape_set_shape(obj, res); |