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

Don't take self by value if we don't have to #498

Closed

Conversation

TimJentzsch
Copy link
Collaborator

Objective

In a lot of functions we currently take self by value instead of reference. This is possible because these values are Copy, so we can still comfortably use them.

However, this might not always be the case. For example, implementing calculated dimensions will cause them to lose the Copy derive, breaking several usages.

Context

I will probably take another stab at implementing calculated dimensions soon and this PR should make that a bit easier.
There are still 42 errors when removing the Clone derive from Dimension, but those probably need .clone() to be slapped into several places.

See #232 for reference as well.

Feedback wanted

Do you think this could have a performance impact?
I measured some performance regressions in the benchmarks, but they appear to be quite flaky on my machine.
So I'm not sure if it's noise or an actual regression.

@TimJentzsch TimJentzsch requested a review from nicoburns June 17, 2023 13:53
@TimJentzsch TimJentzsch added the code quality Make the code cleaner or prettier. label Jun 17, 2023
@jkelleyrtp
Copy link
Member

Looks good to me. There's occasionally a performance tradeoff when using references for copy types.

https://rust-lang.github.io/rust-clippy/master/index.html#/trivially_copy_pass_by_ref

We could try turning on clippy pedantic and see if it labels these are small enough to be just plain copied.

@nicoburns nicoburns closed this Aug 22, 2023
@nicoburns nicoburns reopened this Aug 22, 2023
@TimJentzsch
Copy link
Collaborator Author

Probably not worth it right now and the PR too stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Make the code cleaner or prettier.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants