Commit ba2382d6 authored by Dominik Charousset's avatar Dominik Charousset

Avoid repeated map lookups

parent 41dc4ac4
......@@ -94,34 +94,30 @@ void incoming_stream_multiplexer::operator()(stream_msg::ack_batch&) {
void incoming_stream_multiplexer::operator()(stream_msg::close&) {
CAF_ASSERT(current_stream_msg_ != nullptr);
CAF_ASSERT(current_stream_state_ != streams_.end());
auto i = streams_.find(current_stream_msg_->sid);
if (i != streams_.end()) {
forward_to_downstream();
streams_.erase(i);
}
streams_.erase(current_stream_state_);
}
void incoming_stream_multiplexer::operator()(stream_msg::abort& x) {
CAF_ASSERT(current_stream_msg_ != nullptr);
CAF_ASSERT(current_stream_state_ != streams_.end());
auto i = streams_.find(current_stream_msg_->sid);
if (i != streams_.end()) {
if (i->second.prev_stage == self_->current_sender())
fail(x.reason, nullptr, i->second.next_stage);
if (current_stream_state_->second.prev_stage == self_->current_sender())
fail(x.reason, nullptr, current_stream_state_->second.next_stage);
else
fail(x.reason, i->second.prev_stage);
streams_.erase(i);
}
fail(x.reason, current_stream_state_->second.prev_stage);
streams_.erase(current_stream_state_);
}
void incoming_stream_multiplexer::operator()(stream_msg::downstream_failed&) {
CAF_ASSERT(current_stream_msg_ != nullptr);
CAF_ASSERT(current_stream_state_ != streams_.end());
// TODO: implement me
}
void incoming_stream_multiplexer::operator()(stream_msg::upstream_failed&) {
CAF_ASSERT(current_stream_msg_ != nullptr);
CAF_ASSERT(current_stream_state_ != streams_.end());
// TODO: implement me
}
void incoming_stream_multiplexer::forward_to_upstream() {
......
......@@ -97,31 +97,31 @@ void outgoing_stream_multiplexer::operator()(stream_msg::ack_batch&) {
void outgoing_stream_multiplexer::operator()(stream_msg::close&) {
CAF_ASSERT(current_stream_msg_ != nullptr);
auto i = streams_.find(current_stream_msg_->sid);
if (i != streams_.end()) {
CAF_ASSERT(current_stream_state_ != streams_.end());
forward_to_downstream();
streams_.erase(i);
}
streams_.erase(current_stream_state_);
}
void outgoing_stream_multiplexer::operator()(stream_msg::abort& x) {
CAF_ASSERT(current_stream_msg_ != nullptr);
auto i = streams_.find(current_stream_msg_->sid);
if (i != streams_.end()) {
if (i->second.prev_stage == self_->current_sender())
fail(x.reason, nullptr, i->second.next_stage);
CAF_ASSERT(current_stream_state_ != streams_.end());
if (current_stream_state_->second.prev_stage == self_->current_sender())
fail(x.reason, nullptr, current_stream_state_->second.next_stage);
else
fail(x.reason, i->second.prev_stage);
streams_.erase(i);
}
fail(x.reason, current_stream_state_->second.prev_stage);
streams_.erase(current_stream_state_);
}
void outgoing_stream_multiplexer::operator()(stream_msg::downstream_failed&) {
CAF_ASSERT(current_stream_msg_ != nullptr);
CAF_ASSERT(current_stream_state_ != streams_.end());
// TODO: implement me
}
void outgoing_stream_multiplexer::operator()(stream_msg::upstream_failed&) {
CAF_ASSERT(current_stream_msg_ != nullptr);
CAF_ASSERT(current_stream_state_ != streams_.end());
// TODO: implement me
}
void outgoing_stream_multiplexer::forward_to_upstream() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment