Refactor Vector collection capacity.
Summary:
Stop tracking capacity in the Vector as well as in the underlying ArrayData. We still track m_size in both, but that's used from the jit and is a refactor for another day.
BaseVector::canMutateBuffer would return true if m_arr was the static empty vec. This is hard to reason about and unnecessary, stop doing it.
Don't req::make empty vectors and then call reserve on them; we already have a constructor that pre-allocates, use that. After this, all the remaining callers of reserve need to increment m_version, so just have reserve do it.
Make mutate and reserve always result in a mutable m_arr; then there's no need to assert that it's mutable after calling them, since they already assert it.
Don't implement our own grow method; all the places that were using it could just use existing PackedArray helpers; use those instead.
Don't update m_size in loops where we can avoid it; do it once before the loop.
Add missing unit tests so that we have coverage of all the code touched.
Reviewed By: edwinsmith
Differential Revision:
D4985325
fbshipit-source-id:
fe006a2e0648d4bca1cb7f18360a4f89323e22e5