-
Notifications
You must be signed in to change notification settings - Fork 177
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
refactor: use HashSet instead of Vec for network links #1739
refactor: use HashSet instead of Vec for network links #1739
Conversation
Links are used a lot for `contains` operation.
PR missing one of the required labels: {'documentation', 'new feature', 'bug', 'internal', 'enhancement', 'breaking-change', 'dependencies'} |
@@ -1,3 +1,4 @@ | |||
use std::collections::HashSet; |
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.
Move the use
after the header.
@@ -1,3 +1,4 @@ | |||
use std::collections::HashSet; |
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.
Move the use
after the header.
@@ -752,7 +753,7 @@ impl Network { | |||
tracing::trace!("Update edge (link) {} {}", self.graph[self.idx].zid, zid); | |||
self.update_edge(self.idx, idx); | |||
} | |||
self.graph[self.idx].links.push(zid); | |||
self.graph[self.idx].links.insert(zid); |
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.
Here there is a semantic change where before the same ZenohId
could be present multiple times in the Vec<ZenohIdProto>
while now it can be present only once.
Maybe is it worth adding a debug log if insert(zid)
returns Some
? It would allow to detect if something else is going wrong. What do you think?
@@ -1,3 +1,4 @@ | |||
use std::collections::HashSet; |
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.
Move use
after the header.
@@ -756,7 +757,7 @@ impl Network { | |||
tracing::trace!("Update edge (link) {} {}", self.graph[self.idx].zid, zid); | |||
self.update_edge(self.idx, idx); | |||
} | |||
self.graph[self.idx].links.push(zid); | |||
self.graph[self.idx].links.insert(zid); |
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.
Same comment as above on adding a debug log message is insert(zid)
returns Some
?
No observed performance improvement. |
Links are used a lot for
contains
operation.