Further Function simplification
Summary: Use tag dispatching instead of `enable_if`: it is clearer, it sidesteps the GCC mangling bug, and more importantly the conditional doesn't leak into the symbol, making stack traces and profiles more readable. Testing on a compilation unit with 1000 `Function`s from simple lambdas. Before: ``` folly::impl::Function<int (), false>::Function<main::{lambda()#1}, {lambda()#1}>(main::{lambda()#1}&&, std::enable_if<std::integral_constant<bool, ((sizeof (std::decay<main::{lambda()#1}>::type))<=(sizeof folly::detail::function::Data::small))&&std::is_nothrow_move_constructible<std::decay<main::{lambda()#1}> >::value>::value, folly::detail::Tag>::type)::Ops::call(folly::detail::function&) ``` After: ``` folly::impl::Function<int (), false>::OpsSmall<main::{lambda()#1}>::call(folly::detail::function::Data&) ``` Note that the function type is repeated 5 times before, and only once after. This makes a large difference with long namespaces. Binary size is almost unaffected, compile times slightly better: Before: GCC opt: 22.3 seconds, 4435232 bytes Clang dev: 7.7 seconds, 5257344 bytes After: GCC opt: 18.6 seconds, 4493920 bytes Clang dev: 7.2 seconds, 5469136 bytes Reviewed By: ericniebler Differential Revision: D3231530 fb-gh-sync-id: 6aa76e7f780a8afdbfed8a378f257ceb86dce704 fbshipit-source-id: 6aa76e7f780a8afdbfed8a378f257ceb86dce704
Showing
Please register or sign in to comment