-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
66 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters