Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upWIP: replaced Vec with HashSet in gstreamer muteables #278
Conversation
| vec.retain(|m| m.0 != muteable_id); | ||
| if vec.len() == 0 { | ||
| if let Some(set) = muteables.get_mut(&id) { | ||
| set.retain(|m| m.id != muteable_id); |
This comment has been minimized.
This comment has been minimized.
ferjm
Jul 8, 2019
Member
The benefit of using a HashSet here is to avoid this loop, right? So this should probably be:
if !set.remove(mutable_id) {
warn!("Tried to remove an unknown Muteable");
}| if vec.len() == 0 { | ||
| if let Some(set) = muteables.get_mut(&id) { | ||
| set.retain(|m| m.id != muteable_id); | ||
| if set.len() == 0 { |
This comment has been minimized.
This comment has been minimized.
|
|
||
| lazy_static! { | ||
| static ref BACKEND_BASE_TIME: gst::ClockTime = { gst::SystemClock::obtain().get_time() }; | ||
| } | ||
|
|
||
| struct IdMuteable { | ||
| id: usize, |
This comment has been minimized.
This comment has been minimized.
ferjm
Jul 8, 2019
Member
Players and AudioContexts already have their own ids. I think there is no need to duplicated them here.
This comment has been minimized.
This comment has been minimized.
khodzha
Jul 8, 2019
Author
Contributor
yes, but we have only Weak<Mutex<dyn Muteable>>, is locking mutex just to get an id fine?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| lazy_static! { | ||
| static ref BACKEND_BASE_TIME: gst::ClockTime = { gst::SystemClock::obtain().get_time() }; | ||
| } | ||
|
|
||
| struct IdMuteable { |
This comment has been minimized.
This comment has been minimized.
|
After a discussion with @ferjm it was decided HashSet doesnt provide much of a benefit since in current implementation So I'm closing this PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
khodzha commentedJul 7, 2019
•
edited
@ferjm you've been suggesting HashSet from the start yet because we didn't have an id back then I went with Vec.
But since we already add usize ids to muteables Vec I suppose we can just utilize it for Hash + Eq and replace Vec with HashSet now.
(I'm not sure whether IdMuteable is appropriate naming at all and also whether it should go straight to
lib.rsfile or be separated into another one)