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 clones (fixes #50) #326

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

StefanBossbaly
Copy link
Contributor

What

Removes unnecessary clones

Why

Clones increase memory usage and increase processing time.

How

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

Test

cargo test

Checklist

  • I have self-reviewed this PR
  • I have added tests that prove the feature works or the fix is effective

Copy link
Collaborator

@satlead satlead left a 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?

Copy link
Contributor

@adamdama adamdama left a 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.

@StefanBossbaly
Copy link
Contributor Author

@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.

@satlead satlead added the needs-onboarding Changes which need to be onboarded for testing label Nov 27, 2023
@Nv-Delle1416 Nv-Delle1416 added this to the ripple-1.1.0 milestone Jan 4, 2024
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
@satlead satlead changed the title Remove unnecessary clones Remove unnecessary clones (fixes #50) Jan 8, 2024
@satlead satlead linked an issue Jan 8, 2024 that may be closed by this pull request
@satlead satlead removed a link to an issue Jan 8, 2024
@satlead satlead merged commit 7e8552a into rdkcentral:main Jan 8, 2024
4 checks passed
satlead added a commit that referenced this pull request Jan 8, 2024
* 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>
satlead added a commit that referenced this pull request Jan 8, 2024
* 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>
satlead added a commit that referenced this pull request Jan 12, 2024
* 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>
@satlead satlead modified the milestones: ripple-1.1.0, ripple-1.2.0 Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-onboarding Changes which need to be onboarded for testing
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants