-
Notifications
You must be signed in to change notification settings - Fork 10
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 clones (fixes #50) #326
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement on this one. Was this found by Clippy? if so are we missing lints in our ci?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I love a good cleanup. I second @satlead's question though it would be ace if these could be covered by the code analysis.
@adamdama & @satlead There is https://rust-lang.github.io/rust-clippy/master/#/redundant_clone but it will only catch redundant clones, not unnecessary. Meaning that if an object is cloned and dropped without any actions taking place it will be able to catch that. Unfortunately it looks like cloning an object counts as an action which is why the lint was not triggering. There doesn't look like there is a lint for cloning a whole data structure (i.e. HashMap) to only move out a value. Not sure if it is possible but might be something to bring up to the clippy team. |
Removes unnecessary clones by: 1) Removing the clone() call 2) Borrowing the value instead 3) Defering the clone() call on the item that needs to be cloned and not the whole containing datastructure
808b496
to
4087d0d
Compare
* Remove unnecessary clones Removes unnecessary clones by: 1) Removing the clone() call 2) Borrowing the value instead 3) Defering the clone() call on the item that needs to be cloned and not the whole containing datastructure * Fixed lint and formatting issues --------- Co-authored-by: Sathishkumar <satlead@gmail.com>
* Remove unnecessary clones (fixes #50) (#326) * Remove unnecessary clones Removes unnecessary clones by: 1) Removing the clone() call 2) Borrowing the value instead 3) Defering the clone() call on the item that needs to be cloned and not the whole containing datastructure * Fixed lint and formatting issues --------- Co-authored-by: Sathishkumar <satlead@gmail.com> * Remove unnecessary clones (fixes #50) (#326) * Remove unnecessary clones Removes unnecessary clones by: 1) Removing the clone() call 2) Borrowing the value instead 3) Defering the clone() call on the item that needs to be cloned and not the whole containing datastructure * Fixed lint and formatting issues --------- Co-authored-by: Sathishkumar <satlead@gmail.com> --------- Co-authored-by: Stefan Bossbaly <Sbossb@gmail.com>
* cherry-pick: Remove unnecessary clones (fixes #50) (#326) (#376) * Remove unnecessary clones (fixes #50) (#326) * Remove unnecessary clones Removes unnecessary clones by: 1) Removing the clone() call 2) Borrowing the value instead 3) Defering the clone() call on the item that needs to be cloned and not the whole containing datastructure * Fixed lint and formatting issues --------- Co-authored-by: Sathishkumar <satlead@gmail.com> * Remove unnecessary clones (fixes #50) (#326) * Remove unnecessary clones Removes unnecessary clones by: 1) Removing the clone() call 2) Borrowing the value instead 3) Defering the clone() call on the item that needs to be cloned and not the whole containing datastructure * Fixed lint and formatting issues --------- Co-authored-by: Sathishkumar <satlead@gmail.com> --------- Co-authored-by: Stefan Bossbaly <Sbossb@gmail.com> * fix: Context update (#379) * fix: Context Update not working for extensions * fix: for updating context token if available on boot --------- Co-authored-by: Stefan Bossbaly <Sbossb@gmail.com>
What
Removes unnecessary clones
Why
Clones increase memory usage and increase processing time.
How
Removes unnecessary clones by:
not the whole containing datastructure
Test
cargo test
Checklist