Skip to content
Permalink
Browse files

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 6e26fa9d03ca5b0e78d3e0a78785e7ebda1eb30a
Showing with 6 additions and 7 deletions.
  1. +6 −7 mcrouter/routes/MissFailoverRoute.h
@@ -93,7 +93,7 @@ class MissFailoverRoute {

// Failover
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);
for (size_t i = 1; i < targets_.size(); ++i) {
auto failoverReply = targets_[i]->route(req);
@@ -112,10 +112,9 @@ class MissFailoverRoute {
bestReply = std::move(failoverReply);
}
}
return bestReply;
return std::move(bestReply);
});
}

};

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

} // detail
} // namespace detail

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

0 comments on commit 6e26fa9

Please sign in to comment.
You can’t perform that action at this time.