small_vector improvements
authorNick Terrell <terrelln@fb.com>
Wed, 26 Apr 2017 17:32:25 +0000 (10:32 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 26 Apr 2017 17:40:07 +0000 (10:40 -0700)
commit0ef8ce0d60996be2467fd4ccff324d4786243f27
treee3311f5b0d5f18f927a2f274e884220e98c50dcf
parenta0c640e8e2ff45bc43b9f8d96cd108bb66635bee
small_vector improvements

Summary:
1. `emplace_back()` is broken when there are at least two arguments and one is a reference to inside the vector. See the `ForwardingEmplaceInsideVector` test.
2. Only `push_back(value_type&&)` did exponential growth, every other function grew linearly. The bug is hidden inside of facebook because `goodMallocSize()` grows fast enough to not be horribly slow. When not using jemalloc, it will grow one element at a time.
3. `push_back(value_type const& t)` performed a copy and a move on `t` when `size() == capacity()`. Remove the extra move.

Fixes https://github.com/facebook/folly/issues/541.

Reviewed By: luciang

Differential Revision: D4875084

fbshipit-source-id: eefa76028c6bfd9d7c73af65e8bb9d4baf49b8cb
folly/small_vector.h
folly/test/small_vector_test.cpp