Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor rb_obj_evacuate_ivs_to_hash_table #8934

Merged

Conversation

casperisfine
Copy link
Contributor

That function is a bit too low level to called from multiple places. It's always used in tandem with rb_shape_set_too_complex and both have to know how the object is laid out to update the iv_ptr.

So instead we can provide two higher level function:

  • rb_obj_copy_ivs_to_hash_table to prepare a st_table from an arbitrary oject.
  • rb_obj_convert_to_too_complex to assign the new st_table to the old object, and safely free the old iv_ptr.

Unfortunately both can't be combined into one, because rb_obj_copy_ivar need rb_obj_copy_ivs_to_hash_table to copy from one object to another.

That function is a bit too low level to called from multiple
places. It's always used in tandem with `rb_shape_set_too_complex`
and both have to know how the object is laid out to update the
`iv_ptr`.

So instead we can provide two higher level function:

  - `rb_obj_copy_ivs_to_hash_table` to prepare a `st_table` from an
    arbitrary oject.
  - `rb_obj_convert_to_too_complex` to assign the new `st_table`
    to the old object, and safely free the old `iv_ptr`.

Unfortunately both can't be combined into one, because `rb_obj_copy_ivar`
need `rb_obj_copy_ivs_to_hash_table` to copy from one object
to another.
@casperisfine casperisfine force-pushed the refactor-rb_obj_evacuate_ivs_to_hash_table branch from 5c86bd3 to ac8fdf0 Compare November 16, 2023 17:11
@byroot byroot requested review from tenderlove, peterzhu2118, jemmaissroff and XrXr and removed request for tenderlove November 16, 2023 17:37
@byroot byroot merged commit 94c9f16 into ruby:master Nov 17, 2023
98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants