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

KG-4574: Allow replacing edges for faster diff manipulation #24

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

DGPardo
Copy link
Contributor

@DGPardo DGPardo commented Nov 1, 2024

Introduce a set edges method for faster edition of the Diff Object.

Copy link
Collaborator

@hamishs hamishs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my question

src/diff.rs Outdated
/// Does not check that the node IDs are valid (i.e. not marked as deleted).
/// CAUTION: This replaces existing diff edges by the provided ones.
pub unsafe fn set_edges_unchecked(&mut self, edges: HashMap<Id, HashMap<Id, W>>) {
let _ = std::mem::replace(&mut self.edges.new_or_updated, edges);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between

let _ = std::mem::replace(&mut self.a,b);

And

self.a = b;

In the first case we could return the old value but if we don't want to then is there anything else?

Copy link
Contributor Author

@DGPardo DGPardo Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • remove unnecessary std::mem::replace

@DGPardo DGPardo force-pushed the KG-4574-set-edges-method branch from 3b2b059 to 06678bf Compare November 4, 2024 12:51
@DGPardo DGPardo merged commit f514050 into main Nov 4, 2024
2 checks passed
@DGPardo DGPardo deleted the KG-4574-set-edges-method branch November 4, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants