Boost logo

Boost Users :

Subject: Re: [Boost-users] Compress to buffer
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-01-16 18:12:22


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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net