This is the mail archive of the
mailing list for the libstdc++ project.
Re: [RFC] Vector (string?) growth factor of 1.5 (insted of 2)
Paolo Carlini <firstname.lastname@example.org> writes:
| Gabriel Dos Reis wrote:
| > "Bo Persson" <email@example.com> writes:
| > | I think we should not only measure speed, but also consider the
| > amount of
| > | memory wasted by over allocation.
| > |
| > | If you want maximum speed for a particular container, you should
| > of course
| > | allocate every single byte available for it at once, and be done
| > with it.
| > I agree.
| Well, I also agree, in principle.... This would favor smaller growth
| However, consider the constructor from input iterators that I have "fixed"
| recently to finally use the exponential growth policy which we had
| in such cases it makes little sense talking of "allocate at once", since, in
| general, you cannot know in advance how big is the string that you are going
| to construct (yes, you could pre-allocate all of your real + virtual
| you get the point, I think...)
if the only thing you have is a genuine input iterator you're
effectively stuck. However, if you have at least a bidirectional
iterator, then you can have an idea of the amount staorage you need.
We already have dispatchers that compute those iterator categories.
It might be a good idea to take advantage of them.