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

avoid Function instantiating std::decay over lambdas

Summary:
It turns out that `std::decay` becomes expensive when as widely instantiated as it is.

```name=trunk
$ foundation/scripts/run-perf-compile --syntax folly/futures/test/FutureTest.cpp
     6,336,421,499      instructions:uP
```

```name=branch
$ foundation/scripts/run-perf-compile --syntax folly/futures/test/FutureTest.cpp
     6,287,269,480      instructions:uP
```

Reviewed By: Gownta, luciang

Differential Revision: D32973204

fbshipit-source-id: 75d52fd5ced58f50518913d3c00709bcee27c87b
parent 4da17f04
...@@ -358,7 +358,7 @@ struct FunctionTraits<ReturnType(Args...)> { ...@@ -358,7 +358,7 @@ struct FunctionTraits<ReturnType(Args...)> {
using NonConstSignature = ReturnType(Args...); using NonConstSignature = ReturnType(Args...);
using OtherSignature = ConstSignature; using OtherSignature = ConstSignature;
template <typename F, typename R = CallableResult<std::decay_t<F>&, Args...>> template <typename F, typename R = CallableResult<F&, Args...>>
using IfSafeResult = IfSafeResultImpl<R, ReturnType>; using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
template <typename Fun> template <typename Fun>
...@@ -410,9 +410,7 @@ struct FunctionTraits<ReturnType(Args...) const> { ...@@ -410,9 +410,7 @@ struct FunctionTraits<ReturnType(Args...) const> {
using NonConstSignature = ReturnType(Args...); using NonConstSignature = ReturnType(Args...);
using OtherSignature = NonConstSignature; using OtherSignature = NonConstSignature;
template < template <typename F, typename R = CallableResult<const F&, Args...>>
typename F,
typename R = CallableResult<const std::decay_t<F>&, Args...>>
using IfSafeResult = IfSafeResultImpl<R, ReturnType>; using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
template <typename Fun> template <typename Fun>
...@@ -465,7 +463,7 @@ struct FunctionTraits<ReturnType(Args...) noexcept> { ...@@ -465,7 +463,7 @@ struct FunctionTraits<ReturnType(Args...) noexcept> {
using NonConstSignature = ReturnType(Args...) noexcept; using NonConstSignature = ReturnType(Args...) noexcept;
using OtherSignature = ConstSignature; using OtherSignature = ConstSignature;
template <typename F, typename R = CallableResult<std::decay_t<F>&, Args...>> template <typename F, typename R = CallableResult<F&, Args...>>
using IfSafeResult = IfSafeResultImpl<R, ReturnType>; using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
template <typename Fun> template <typename Fun>
...@@ -517,9 +515,7 @@ struct FunctionTraits<ReturnType(Args...) const noexcept> { ...@@ -517,9 +515,7 @@ struct FunctionTraits<ReturnType(Args...) const noexcept> {
using NonConstSignature = ReturnType(Args...) noexcept; using NonConstSignature = ReturnType(Args...) noexcept;
using OtherSignature = NonConstSignature; using OtherSignature = NonConstSignature;
template < template <typename F, typename R = CallableResult<const F&, Args...>>
typename F,
typename R = CallableResult<const std::decay_t<F>&, Args...>>
using IfSafeResult = IfSafeResultImpl<R, ReturnType>; using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
template <typename Fun> template <typename Fun>
......
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