• Yedidya Feldblum's avatar
    specialize Function internals over trivially-copyable callables · a32a7701
    Yedidya Feldblum authored
    Summary:
    `Function` requires an instantiation of a control function for every unique callable type. There are two control functions, named `execSmall` and `execBig`.
    
    But instantiation is expensive for build speed and build size - especially instantiation per unique callable type.
    
    An hypothesis is that it is common for callable types to be trivially-copyable. In particular, that it is common to have lambdas with implicit by-reference captures and no other captures, as `[&] { /* ... */ }`.
    
    So we introduce a new dispatch class, `DispatchSmallTrivial`, with a member function `exec` which is instantiated as few times as possible and which is used for all trivially-copyable callable types.
    
    Reviewed By: ot, luciang
    
    Differential Revision: D32932586
    
    fbshipit-source-id: 34ecad6b6bcbbc3ed379e3d32babf04c91d76557
    a32a7701
FunctionTest.cpp 35.3 KB