Estimate the number of primitives that will be created during flatten… …
…ing and pre-allocate the vector to that size