Is there a faster way than what I have below to append a number of floats to a vector, where the source floats come from const float buffers? The example below, which is what I currently have, gets called in a loop to append somewhere between 1-16 floats at a time. At any one time, that function can be called 1000's of times within a loop to fill the dst
buffer. The ptr
object may be different each time. This is dealing with 3D geometry.
void appendFloats(std::vector<float>& dst, const float* ptr, uint32_t count) {
for (uint32_t i = 0; i < count; i) {
dst.push_back(ptr[i]);
}
}
CodePudding user response:
The fastest linear way is
dst.insert(dst.end(), ptr, ptr count);
Even a faster way is using the parallel algorithm or OMP.