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

Optimise mpsc tee #74

Merged
merged 7 commits into from
Nov 24, 2020
Merged

Optimise mpsc tee #74

merged 7 commits into from
Nov 24, 2020

Conversation

johndelcastillo
Copy link
Contributor

No description provided.

@@ -145,12 +145,11 @@ impl Transform for Tee {
return match self.behavior {
ConsistencyBehavior::IGNORE => {
self.tx
.send(ChannelMessage::new_with_no_return(m))
.try_send(ChannelMessage::new_with_no_return(m))
Copy link
Member

Choose a reason for hiding this comment

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

do you want to extend this behaviour to the other modes? E.g. LOG should log to the other channel when try_send fails and FAIL should fail the whole request

default_topic
});

let built_topics = topics.iter().map(|(k, v)| (k.to_owned(), v.unwrap_or(5))).collect();
Copy link
Member

Choose a reason for hiding this comment

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

you can use into_iter to move ownership of the objects in the iterator into the map. to_owned usually results in a clone.

The compiler should optimise this away, and it doesn't really matter as this is just config loading, but something to keep in mind if you want to get things out of an iterated collection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

righto, i thought there was a better way to do this goo

@benbromhead benbromhead merged commit 4bcb40e into main Nov 24, 2020
@benbromhead benbromhead deleted the optimise-mpsc-tee branch December 20, 2020 21:46
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