Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move out failover reply to avoid copy
Summary: I cought this when using move only type in Carbon struct. In general this looks like a good fix to avoid copying reply.

Reviewed By: stuclar

Differential Revision: D18366993

fbshipit-source-id: be63c45608ec3ffbc1671715fc09908dff603ea3
  • Loading branch information
Alexander Zhavnerchik authored and facebook-github-bot committed Nov 7, 2019
1 parent 951b33b commit 6e26fa9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions mcrouter/routes/MissFailoverRoute.h
Expand Up @@ -93,7 +93,7 @@ class MissFailoverRoute {


// Failover // Failover
return fiber_local<RouterInfo>::runWithLocals( return fiber_local<RouterInfo>::runWithLocals(
[ this, &req, bestReply = std::move(reply) ]() mutable { [this, &req, bestReply = std::move(reply)]() mutable {
fiber_local<RouterInfo>::addRequestClass(RequestClass::kFailover); fiber_local<RouterInfo>::addRequestClass(RequestClass::kFailover);
for (size_t i = 1; i < targets_.size(); ++i) { for (size_t i = 1; i < targets_.size(); ++i) {
auto failoverReply = targets_[i]->route(req); auto failoverReply = targets_[i]->route(req);
Expand All @@ -112,10 +112,9 @@ class MissFailoverRoute {
bestReply = std::move(failoverReply); bestReply = std::move(failoverReply);
} }
} }
return bestReply; return std::move(bestReply);
}); });
} }

}; };


namespace detail { namespace detail {
Expand All @@ -136,7 +135,7 @@ typename RouterInfo::RouteHandlePtr makeMissFailoverRoute(
std::move(targets), returnBestOnError); std::move(targets), returnBestOnError);
} }


} // detail } // namespace detail


template <class RouterInfo> template <class RouterInfo>
typename RouterInfo::RouteHandlePtr makeMissFailoverRoute( typename RouterInfo::RouteHandlePtr makeMissFailoverRoute(
Expand All @@ -161,6 +160,6 @@ typename RouterInfo::RouteHandlePtr makeMissFailoverRoute(
return detail::makeMissFailoverRoute<RouterInfo>( return detail::makeMissFailoverRoute<RouterInfo>(
std::move(children), returnBestOnError); std::move(children), returnBestOnError);
} }
} // mcrouter } // namespace mcrouter
} // memcache } // namespace memcache
} // facebook } // namespace facebook

0 comments on commit 6e26fa9

Please sign in to comment.