X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FFBVector.h;h=c773a7f963dc023b01942eba114345d1449002cf;hb=49e4875c1e7d55df5913410539d299b7aa3c62bc;hp=754ebfef5f48a93d6a703d34ea58d6ae4c8162ae;hpb=3bb128276a7edeae46d14f4a345298c3a1e983ba;p=folly.git diff --git a/folly/FBVector.h b/folly/FBVector.h index 754ebfef..c773a7f9 100644 --- a/folly/FBVector.h +++ b/folly/FBVector.h @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -653,7 +654,7 @@ private: } // done - void relocate_done(T* dest, T* first, T* last) noexcept { + void relocate_done(T* /*dest*/, T* first, T* last) noexcept { if (folly::IsRelocatable::value && usingStdAllocator::value) { // used memcpy; data has been relocated, do not call destructor } else { @@ -965,6 +966,12 @@ public: } void shrink_to_fit() noexcept { + if (empty()) { + // Just skip reallocation. + *this = fbvector(); + return; + } + auto const newCapacityBytes = folly::goodMallocSize(size() * sizeof(T)); auto const newCap = newCapacityBytes / sizeof(T); auto const oldCap = capacity(); @@ -1586,6 +1593,16 @@ void swap(fbvector& lhs, fbvector& rhs) noexcept { //----------------------------------------------------------------------------- // other +namespace detail { + +// Format support. +template +struct IndexableTraits> + : public IndexableTraitsSeq> { +}; + +} // namespace detail + template void compactResize(fbvector* v, size_t sz) { v->resize(sz);