Don't take self
by value if we don't have to
#498
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
In a lot of functions we currently take
self
by value instead of reference. This is possible because these values areCopy
, 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 fromDimension
, 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.