From 70e3e08881d3f7f59828776de6af8b1898ebfe77 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 1 Nov 2023 11:05:46 -0400 Subject: [PATCH] Optimize for too complex objects --- variable.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/variable.c b/variable.c index be04b34527..082d7537a5 100644 --- a/variable.c +++ b/variable.c @@ -2202,6 +2202,7 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name) if (!rb_shape_obj_too_complex(obj)) { rb_evict_ivars_to_hash(obj, shape); } + if (!st_delete(RCLASS_IV_HASH(obj), (st_data_t *)&id, (st_data_t *)&val)) { val = Qundef; } @@ -2212,8 +2213,9 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name) if (!rb_shape_obj_too_complex(obj)) { rb_evict_ivars_to_hash(obj, shape); } - if (rb_st_lookup(ROBJECT_IV_HASH(obj), (st_data_t)id, (st_data_t *)&val)) { - rb_st_delete(ROBJECT_IV_HASH(obj), (st_data_t *)&id, 0); + + if (!st_delete(ROBJECT_IV_HASH(obj), (st_data_t *)&id, (st_data_t *)&val)) { + val = Qundef; } } break;