16 Jan
2014
16 Jan
'14
11:12 p.m.
On 17/01/2014 11:58, Quoth Kenneth Adam Miller:
Ok. Well all my producer does is append. Vector sounds good for the ability to do random access fast like an array, and you said that vector has good append speed.
Random access should be the same speed for both. Appending will be slightly faster for the vector than for the string, because the string also has to write a new terminator. But if you can get the data to be appended as a complete sequence (either a pair of iterators or a start pointer and length), then string typically wins again, as you can use a single .append() instead of multiple .push_back()s. But as always, these are just approximate guidelines; to be really sure, you need to test and measure.