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

Replaced set_difference to copy_if because it is used on unordered_set #226

Merged
merged 1 commit into from
May 11, 2023

Conversation

achim-k
Copy link
Collaborator

@achim-k achim-k commented May 10, 2023

Public-Facing Changes

  • Correct calculation of removed topics and services while updating connection graph.

Description

Original commit: foxglove/ws-protocol#437

Now in websocket_server.hpp we have:

https://github.com/foxglove/ws-protocol/blob/5cdda39d9ed4e8287a5d27406f5e4f368bd0e1fc/cpp/foxglove-websocket/include/foxglove/websocket/websocket_server.hpp#L1158-L1159

And to find difference between them function set_difference is used:

https://github.com/foxglove/ws-protocol/blob/5cdda39d9ed4e8287a5d27406f5e4f368bd0e1fc/cpp/foxglove-websocket/include/foxglove/websocket/websocket_server.hpp#L1203-L1206

According to documentation of std::set_difference it can be used only for sorted ranges (which is not a case when we use unorderd_set).

To have O(1) complexity for insert and search operations on unordered_set, I suggest to use std::copy_if function to find difference between two unordered sets.

Correct calculation of removed topics and services while updating connection graph.

Originally commit: foxglove/ws-protocol#437
@achim-k achim-k enabled auto-merge (squash) May 10, 2023 18:11
@achim-k achim-k merged commit 451acb9 into main May 11, 2023
6 checks passed
@achim-k achim-k deleted the fix/set_difference_unordered_set branch May 11, 2023 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants