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

Remove unnecessary friend class declarations of CowData. #100650

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ivorforce
Copy link
Contributor

@Ivorforce Ivorforce commented Dec 20, 2024

This is a small cleanup I did while doing sanity checks for #100619.
The friend class declarations are unnecessary. They should be removed because they increase coupling. It additionally makes no sense to have friend classes because CowData should be designed such that it can be used from any class, and not just some known specific classes.

There are only a few affected spots:

_ref() calls can be replaced with operator=(const CowData &) calls. The resulting call is the exact same:

void operator=(const CowData<T> &p_from) { _ref(p_from); }

Forward declarations can also be removed. Two headers were passively using them before (visual_shader and vector). I moved the forward declarations to the appropriate spots.

Finally, I also made _get_alloc_size and _get_alloc_size_checked static. This is a small change that doesn't warrant a separate PR. It does not make sense to have the functions be member functions, because it is relied upon that allocation sizes are consistent across different instances of CowData. It has to be deterministic by class alone.

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.

3 participants