Skip to content

Delete VariantGetInternalPtr and VariantImplicitConvert, replace with VariantInternalAccessor #105254

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Ivorforce
Copy link
Member

@Ivorforce Ivorforce commented Apr 10, 2025

Includes / supersedes #105246.
I recommend looking briefly at the above PR, but merging this one (without merging the above first), because it ultimately creates the better end picture.

Explanation

VariantGetInternalPtr, VariantImplicitConvert (introduced temporarily in #105246) and VariantInternalAccessor do pretty much the same thing: They allow users to get values and assign values when working with Variant, when the underlying type is known to match.

Having 3 types for the same task is not a great idea, because code will diverge. In this PR, I am deduplicating functionality by deleting VariantGetInternalPtr and VariantImplicitConvert, and merely using VariantInternalAccessor in all cases.
Doing this allows us to confidently maintain VariantInternalAccessor going forwards, instead of having to maintain a convoluted mess of different ways to do the same thing.

The PR is big and scary, but almost all of the changes are pretty safe search-and-replace.

Notes

Through search-and-replace, some VariantInternalAccessor uses ended up using the following style:

VariantInternalAccessor<A>::get(variant) = b;
// Instead of 
VariantInternalAccessor<A>::set(variant, b);

This looks a bit weird, but it's not detrimental to performance, using a reference to assign to the value. This can get cleaned up if it's confusing in the future.

…mplicitly converted to and from `Variant`.

De-duplicate a lot of `VariantGetInternalPtr`, `VariantInternalAccessor`, `VariantInitializer` and `VariantDefaultInitializer`.
Replace uses with `VariantInternalAccessor`.
@Ivorforce Ivorforce added this to the 4.x milestone Apr 10, 2025
@Ivorforce Ivorforce requested review from a team as code owners April 10, 2025 18:27
@Ivorforce Ivorforce changed the title lete VariantGetInternalPtr and VariantImplicitConvert, replace with VariantInternalAccessor Delete VariantGetInternalPtr and VariantImplicitConvert, replace with VariantInternalAccessor Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant