From d6c0e8e7294cb3a5c259153ab13d080c30bf8035 Mon Sep 17 00:00:00 2001 From: Hannes Roth Date: Mon, 26 Jan 2015 09:08:49 -0800 Subject: [PATCH] (Wangle) Don't add an extra value() call for makeFuture(Try) Summary: Not sure why we'd need that? This avoids a move, I think. Test Plan: Run all the tests. Also unbreaks this code, which used to work at some point. https://phabricator.fb.com/diffusion/FBCODE/browse/master/taoThriftService/TaoServiceHandler.cpp;a27bc2ef36cd671d65ae0fd2cc1fb1f823e68ae4$246 Reviewed By: hans@fb.com Subscribers: trunkagent, folly-diffs@, jsedgwick FB internal diff: D1800619 Signature: t1:1800619:1422053903:f9e65a0be3d820a9a9989b3cf5dfaf2a61e2e900 --- folly/futures/Future-inl.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/folly/futures/Future-inl.h b/folly/futures/Future-inl.h index 4b12706f..e14754b7 100644 --- a/folly/futures/Future-inl.h +++ b/folly/futures/Future-inl.h @@ -497,11 +497,9 @@ makeFuture(E const& e) { template Future makeFuture(Try&& t) { - if (t.hasException()) { - return makeFuture(std::move(t.exception())); - } else { - return makeFuture(std::move(t.value())); - } + Promise::type> p; + p.fulfilTry(std::move(t)); + return p.getFuture(); } template <> -- 2.34.1