Make folly::small_vector friendly to compiler optimizations
Summary: This includes several enhancements to folly::small_vector: Eliminate overhead accessing vector elements by making heap_ points to element 0 of the vector. To get start address only dispatch is required as shown below: value_type* data () { // Dispatch between heap_ or internalStorage, return isExtern() ? heap_ : &internalStorage_; } Reorganize the implementation by recording if capacity is stored internally or on the heap in "size". As a result the maximum vector size is half smaller. This is the only visible behavior change of this PR. Assuming size is 64 bits then - bit63 determines if vector elements are stored in internalStorage_ or externally in the heap - bit62 determines if vector capacity is stored internally or on the heap - bit61..bit0 contain the size of the vector. Reduce the overhead of updating size buy adding incrementSize functions. Tune emplace_back function and vector initialization. Reviewed By: yfeldblum Differential Revision: D24413105 fbshipit-source-id: b447704832af9c734be51aa6d23b8cb4be69a8bf
Showing
This diff is collapsed.
Please register or sign in to comment