• Sven Over's avatar
    Fast-path destructor · 9ee00d31
    Sven Over authored
    Summary:
    Optimise the destruction of default-constructed and moved-out Function objects. Instead of calling a function pointer that is set to a no-op function, use `nullptr` to signal emptyness of that function pointer and check if it is `nullptr` before invoking.
    This adds additional branching in a few places: not only in the destructor, but also in the move constructor, as well as in the little used `hasAllocatedMemory`. The effect of getting rid of calls to a no-op function pointer should outweigh that.
    
    Reviewed By: djwatson
    
    Differential Revision: D8694003
    
    fbshipit-source-id: 42972805b2ade255cf1dcc98e54985b1524daa73
    9ee00d31
main.cpp 14.1 KB