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

Define and use typed xvREFCNT_inc() macros #22416

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented Jul 19, 2024

These new macros take and return pointers to specific subtypes of SV, rather than the generic SvREFCNT_inc() family. As such they avoid needing to cast the result back.

This results in neater, easier-to-read code in a variety of places. It removes many entirely-redundant calls to the MUTABLE_xV macro. It also leaves a space for possible future expansion later on by having the macros additionally assert on the SvTYPE in -DDEBUGGING builds.

@leonerd leonerd added the squash-before-merge Author must squash the commits down before merging to blead label Jul 19, 2024
@leonerd leonerd changed the title Define and use typed xV_REFCNT_inc() macros Define and use typed xvREFCNT_inc() macros Jul 19, 2024
@leonerd leonerd force-pushed the typed-refcnt-macros branch from 22f43d4 to 6fe12e9 Compare July 20, 2024 00:16
Create specific macros for incrementing the refcount of an AV, CV, GV or
HV, returning a typed pointer to avoid the caller needing to cast the
result. This yields neater easier-to-read code.

While not implemented here, this gives an opportunity to add an
`assert()` check on the SvTYPE of the structure being adjusted, for
extra debug checking during debugging builds.
@leonerd leonerd force-pushed the typed-refcnt-macros branch from 6fe12e9 to 347434c Compare July 22, 2024 14:46
@leonerd
Copy link
Contributor Author

leonerd commented Jul 22, 2024

force-pushed to squash all the commits into one, and give them a better commit message

@leonerd leonerd removed the squash-before-merge Author must squash the commits down before merging to blead label Jul 22, 2024
@leonerd leonerd merged commit de762f9 into Perl:blead Jul 22, 2024
33 checks passed
@leonerd leonerd deleted the typed-refcnt-macros branch July 22, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants