Commit e050deab authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Move an exception_ptr in exceptionStr

Summary: [Folly] Move an `exception_ptr` in `exceptionStr`, which should be ever-so-slightly cheaper than copying it since that may avoid atomic refcount operations. It's not much cheaper overall because the throw/catch machinery remains expensive.

Reviewed By: ot, luciang

Differential Revision: D22529858

fbshipit-source-id: 7e5d4ec5c1ca601a766c63133ae759651ae7be85
parent 0df06cbe
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <folly/ExceptionString.h> #include <folly/ExceptionString.h>
#include <utility>
namespace folly { namespace folly {
/** /**
...@@ -40,7 +42,7 @@ fbstring exceptionStr(std::exception_ptr ep) { ...@@ -40,7 +42,7 @@ fbstring exceptionStr(std::exception_ptr ep) {
return catch_exception( return catch_exception(
[&]() -> fbstring { [&]() -> fbstring {
return catch_exception<std::exception const&>( return catch_exception<std::exception const&>(
[&]() -> fbstring { std::rethrow_exception(ep); }, [&]() -> fbstring { std::rethrow_exception(std::move(ep)); },
[](auto&& e) { return exceptionStr(e); }); [](auto&& e) { return exceptionStr(e); });
}, },
[]() -> fbstring { return "<unknown exception>"; }); []() -> fbstring { return "<unknown exception>"; });
......
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