• Nathan Bronson's avatar
    UninitializedMemoryHacks · 7cf58370
    Nathan Bronson authored
    Summary:
    This diff adds helper functions that can resize std::string or std::vector
    without constructing or initializing new elements.  They are designed
    for retroactively optimizing code where touching every element twice
    (or touching never-used elements once) shows up in profiling, and where
    restructuring the code to use fixed-length arrays or IOBuf-s would
    be difficult.
    
    Implementations are provided for 5 string implementations (pre-c++11
    libstdc++, libstdc++ with SSO, libc++, std::basic_fbstring, and MSVC)
    and 3 vector implementations (libstdc++, libc++, and MSVC).  On an
    unsupported platform you will hopefully get a #warn if you include
    UninitializedMemoryHacks.h followed by a linker error if you actually
    use it.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D5102679
    
    fbshipit-source-id: 536c00eabae4cdb8a0affe3e919a372f4dc51ac5
    7cf58370
UninitializedMemoryHacksODR.cpp 760 Bytes