diff options
author | Peter Zhu <[email protected]> | 2023-11-01 11:05:46 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-11-01 11:05:46 -0400 |
commit | 70e3e08881d3f7f59828776de6af8b1898ebfe77 (patch) | |
tree | 351efa711902c412c00ca3e460caef5c86808ebd /variable.c | |
parent | e80ca70b9bd1ccfa319790475dc9c0dd125f4f0d (diff) |
Optimize for too complex objects
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 6 |
1 files 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; |